[英]Loading AWS credentials from a Java servlet on a Lotus Domino server on Linux
[英]Connect to AD using credentials from Linux Server
我正在嘗試使用為Linux服務器創建的憑據連接到活動目錄服務器。 服務器上有一個Web界面,用於提供憑據,但是我無法使用所提供的憑據進行連接。 為了進行故障排除,我只是嘗試使用服務器上代碼所使用的相同方法從Java中的本地計算機進行連接。
public static void main(String[] args) throws NamingException {
final String ldapAdServer = "ldap://server:port";
final String ldapSearchBase = "OU=Users,OU=xxx,DC=yyy,DC=zzz,DC=aaa,DC=com";
final String ldapUsername = "user";
final String ldapPassword = "password";
final String ldapAccountToLookup = "lookup";
final String dc = ",DC=yyy,DC=zzz,DC=aaa,DC=com";
final String ou = ",OU=Uncommon Users,OU=xxx";
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.SECURITY_AUTHENTICATION, "simple");
if(ldapUsername != null) {
env.put(Context.SECURITY_PRINCIPAL, "CN=" + ldapUsername + ou + dc);
}
if(ldapPassword != null) {
env.put(Context.SECURITY_CREDENTIALS, ldapPassword);
}
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapAdServer);
// the following is helpful in debugging errors
//env.put("com.sun.jndi.ldap.trace.ber", System.err);
LdapContext ctx = new InitialLdapContext(env, null);
ConnectLdap ldap = new ConnectLdap();
try {
ldap.findUsers(ctx, ldapSearchBase);
ldap.findAccountByAccountName(ctx, ldapSearchBase, ldapAccountToLookup);
} catch(Exception e) {
e.printStackTrace();
}
}
有很多類似的問題,例如Java ldap身份驗證問題 ,應使用cn而不是uid來解決。 這一個隨機獲取LDAP錯誤49,隨機用戶的數據52e? 以及這一個LDAP + Java Aplication Authentication錯誤代碼49-52e ,其中AD不允許匿名綁定,因為我提供了用戶名和密碼,所以我認為我不想這樣做。 這個LDAP:錯誤代碼49-簡單綁定失敗:NT_STATUS_LOGON_FAILURE ,其中問題試圖使用相對可分辨的名稱進行連接,而我也不認為我在這樣做。 我可以使用此用戶名和密碼與客戶端建立連接,導航至與之連接的用戶,並獲得該用戶的完整專有名稱。 我在security_principal中提供了完整的dn,我缺少什么?
這是嘗試構造InitialLdapContext時發生的異常
Exception in thread "main" javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1
這條線
env.put(Context.SECURITY_PRINCIPAL, "CN=" + ldapUsername + ou + dc);
應該
env.put(Context.SECURITY_PRINCIPAL, ldapUsername@dc1.dc2.dc3.dc4);
如果您使用的是客戶端,則其屬性為userPrincipalName
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.