connection Object

Desription

The connection object provides access to the LDAP operations. It is created by a call to the createConnection method.

Methods

void connect(options, success, error)

Initializes a connection to the specified LDAP server, starting TLS if necessary.

Example

connection.connect({
        uri: "ldap://10.10.1.0:389"
    }, function(e) {
        // Success
        Ti.API.info(JSON.stringify(e));
    }, function(e) {
        // Error
        Ti.API.error(JSON.stringify(e));
        alert(e.message);
    });

void disconnect()

Disconnects from the LDAP server.

object simpleBind(options, success, error)

Performs an LDAP simple bind operation, which authenticates using a bind DN and password, and returns a request object.

Example

connection.simpleBind({
        dn: dn.value,
        password: password.value
    }, function(e) {
        // Success
        Ti.API.info(JSON.stringify(e));
    }, function(e) {
        // Error
        Ti.API.error(JSON.stringify(e));
        alert(e.message);
    });

object saslBind(options, success, error)

Performs an LDAP SASL bind request and returns a request object. A SASL bind includes a SASL mechanism name and optional set of credentials.

Example

connection.saslBind({
        mech: "DIGEST-MD5",
        password: password.value,
        authorizationId: authorizationId.value,
        authenticationId: authenticationId.value
    }, function(e) {
        // Success
        Ti.API.info(JSON.stringify(e));
    }, function(e) {
        // Error
        Ti.API.error(JSON.stringify(e));
        alert(e.message);
    });

object search(options, success, error)

Performs a search on an LDAP directory server and returns a request object. If the search is successful, a searchResult object is returned in the result property of the success callback.

Example

var searchRequest = connection.search({
        async: true,
        base: base.value,
        scope: ldap.SCOPE_CHILDREN,
        filter: filter.value.length > 0 ? filter.value : null,
        attrs: attrs.value.length > 0 ? attrs.value.split(',') : null,
        async: asyncSwitch.value,
        timeLimit: timeLimit.value.length > 0 ? timeLimit.value : null
    }, function(e) {
        showSearchResult(e.result);
    }, function(e) {
        // Error
        Ti.API.error(JSON.stringify(e));
        alert(e.message);
    });

Properties

License

Copyright(c) 2011-2013 by Appcelerator, Inc. All Rights Reserved. Please see the LICENSE file included in the distribution for further details.