我在Java中創建了一個Active Directory(winserver 2012)LDAP身份驗證器,在這種情況下,當AD用戶名包含dost(。)時,身份驗證失敗,例外:如果用戶名包含點(。),Active Directory LDAP身份驗證失敗
javax.naming.AuthenticationException: [LDAP: error code 49 - 8009030C: LdapErr: DSID-0C0904F8, comment: AcceptSecurityContext error, data 52e, v23f0
如果用戶名不包含dot,則認證。工作正常。
有代碼:
private DirContext getDirContext(String username, String password) {
...
Hashtable<String, String> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5");
env.put(Context.PROVIDER_URL, "LDAP://server.test.local:389");
env.put(Context.SECURITY_PRINCIPAL, "test.user");
env.put(Context.SECURITY_CREDENTIALS, "password");
env.put(Context.REFERRAL, "follow");
env.put("java.naming.ldap.attributes.binary", "objectGUID objectSid");
DirContext ctx;
try {
ctx = new InitialLdapContext(env, null);
} catch (NamingException ex) {
getLogger().log(Level.WARNING,
"ACTIVE DIRECTORY - AUTHENTICATION ERROR: " + ex);
}
return ctx;
}
我試圖取代圓點%2E,我試圖完整的用戶名([email protected]),但這些並沒有解決我的問題。
有沒有人有任何想法?謝謝。
我認爲你需要添加域(即:DOMAIN \\ +用戶) 參見:http://stackoverflow.com/questions/16570222/how-to-authenticate-against- active-directory-via-ldap-over-tls – jjhavokk
Context.SECURITY_PRINCIPAL不需要斷言,例如'cn = test.user'嗎? –
它沒有cn =的作品,但我會檢查它,並與域/明天。 – user2938801