Skoude
Skoude

Reputation: 41

dartlang and dartdap library and connection to active directory

I was looking for a good ldap library for Dart for connecting Microsoft Active Directory. I found dartdap, but I can't seem to get it working. I'm 100% shure that my CN and password is correct, because I can connect to Active directory for example with lpap browser.

The error I get is: Uncaught Error: Invalid Credentials (49) msg=80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1

The ldap.yaml looks like this (address, password and username scrambled off course)

# LDAP configuration file
# default is used if no connection name is specified
default:
  port: 389
  host: xxx.xx.com
  bindDN: cn=testaccount
  password:  xxxxxxxx

And the ldaptest.dart looks like this:

void readDataFromLDAPServer() {
  var ldapConfig = new LDAPConfiguration("ldap.yaml","default");
  var attrs = ["dn", "cn", "objectClass"];
  var filter = Filter.substring("cn=A*");
  var notFilter = Filter.not(filter);  

  ldapConfig.getConnection().then( (LDAPConnection ldap) {
    ldap.search("dc=example,dc=com", filter, attrs).
    listen( (SearchEntry entry) => print('Found $entry'));

    // we expect to find non A entries  
    ldap.search("dc=example,dc=com", notFilter, attrs)
      .listen( (SearchEntry entry) {
        //print("Not search = ${entry}");
        // todo: test entries.
      });

  });

}

Any idea, what might be wrong?

Upvotes: 4

Views: 1397

Answers (1)

ipkwena
ipkwena

Reputation: 21

I am using the code below to successfully bind to a Microsoft AD server:

  var host = "ip_address";
  var ssl = false; 
  var port = null; 
  var bindDN = "[email protected]";
  var password = "password";

  var connection = new LdapConnection(host: host);
  connection.setProtocol(ssl, port);
  connection.setAuthentication(bindDN, password);

Please note that my binding code differs from what you are using. I am also using an_ldap client for Dart 2.

Upvotes: 2

Related Questions