简体   繁体   中英

Get Active Directory connection through glassfish jndi resource

I'm trying to get an LDAP-Connection with the attributes provided by a glassfish custom-resource.

My jndi settings:

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

This is how I get the connection in Java:

Context initCtx = new InitialContext();
DirContext ctx = (DirContext) initCtx.lookup("CMDB2LDAP");

This works perfectly with OpenLDAP but when I try to connect to an AD 2003 I get the following Exception:

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 ''

When I create my own DirContext and put exactly the same properties in it, the connection works flawlessly.

I would prefer to get the connection settings from glassfish for the sake of easy administration.

尝试添加java.naming.referral = follow作为另一个属性,看看是否java.naming.referral = follow

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM