我正在尝试使用glassfish自定义资源提供的属性获取ldap连接。
我的JNDI设置:
Resourcetype: javax.naming.directory.Directory
Factory-Class: com.sun.jndi.ldap.LdapCtxFactory
Parameters:
java.naming.security.credentials = myPassword
java.naming.security.principal = cn=ldapUser,ou=myOrganization,dc=myDomain,dc=net
URL = ldap://ldapserver/ou=myOrganization,dc=myDomain,dc=net
这就是我在爪哇的联系方式:
Context initCtx = new InitialContext();
DirContext ctx = (DirContext) initCtx.lookup("CMDB2LDAP");
这在openldap中非常有效,但是当我尝试连接到ad 2003时,会出现以下异常:
javax.naming.NamingException: [LDAP: error code 1 - 00000000: LdapErr: DSID-0C090627, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, vece]; remaining name ''
当我创建自己的dircontext并将完全相同的属性放在其中时,连接就完美地工作了。
为了便于管理,我宁愿从glassfish获取连接设置。