我想知道我应该指定什么“主体”来登录 Active Directory 服务器。委托人应该是我尝试登录的 AD 中的用户吗?或者它可以是我指定的域中的用户,只要该用户具有访问 AD 的权限?
我尝试使用凭据错误 49。但我可以使用安装 AD 的服务器的管理员帐户使用 ldp.exe 登录到 AD。
这是我的代码。非常感谢您的及时帮助。
Hashtable env= new Hashtable(11);
env.put(Context.SECURITY_AUTHENTICATION,"simple"); // Also tried none w/ the same error
// What principal should I use??
env.put(Context.SECURITY_PRINCIPAL,"CN=Ross,OU=Eng,DC=RossInc");//User
//env.put(Context.SECURITY_PRINCIPAL, user + "@" + domain); // Tried w/ the same error
env.put(Context.SECURITY_CREDENTIALS, "ross");//Password
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,"ldap://myserver:389/DC=RossInc");
DirContext ctx = new InitialDirContext(env); <-- Fails with AuthenticationException: [LDAP: error code 49 - 8009030C