我正在为Dart寻找一个好的ldap库来连接Microsoft Active Directory。我找到了dartdap,但我似乎无法让它工作。我百分之百地保证我的CN和密码是正确的,因为我可以使用lpap浏览器连接到Active目录。
我得到的错误是: 未捕获错误:凭据无效(49)msg = 80090308:LdapErr:DSID-0C0903A9,注释:AcceptSecurityContext错误,数据52e,v1db1
ldap.yaml看起来像这样(地址,密码和用户名当然乱了)
# LDAP configuration file
# default is used if no connection name is specified
default:
port: 389
host: xxx.xx.com
bindDN: cn=testaccount
password: xxxxxxxx
ldaptest.dart看起来像这样:
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.
});
});
}
任何想法,可能出现什么问题?
答案 0 :(得分:1)
我正在使用下面的代码成功绑定到Microsoft AD服务器:
var host = "ip_address";
var ssl = false;
var port = null;
var bindDN = "accountname@domain.name";
var password = "password";
var connection = new LdapConnection(host: host);
connection.setProtocol(ssl, port);
connection.setAuthentication(bindDN, password);
请注意,我的绑定代码与您使用的绑定代码不同。我还在Dart 2中使用an_ldap客户端。