2013-02-25 85 views
0

如何知道我的活動目錄的所有屬性?LDAP + Java:如何知道我的活動目錄的名稱

我看到了一個像「ou = People」的例子,但我不知道如何訪問我公司特有的名字「People」。我沒有訪問LDAP(或者我不知道如何),所以我不知道我想要放什麼。

DirContext ctx = null; 

      Hashtable<String, Object> env = new Hashtable<String, Object>(); 
      env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); 
      env.put(Context.PROVIDER_URL, "ldap://"+serverAddress+":389"); 

      env.put(Context.SECURITY_AUTHENTICATION, "simple"); 
      env.put(Context.SECURITY_PRINCIPAL, DOMAIN+username); 
      env.put(Context.SECURITY_CREDENTIALS, password); 

      try { 
       ctx = new InitialDirContext(env); 
       Attributes matchAttrs = new BasicAttributes(true); // ignore attribute name case 

      matchAttrs.put(new BasicAttribute("mail", "[email protected]")); 
      Attributes attrs = ctx.getAttributes(""); 

      // Search for objects that have those matching attributes 
      NamingEnumeration<SearchResult> answer = ctx.search("ou=Users", matchAttrs); 

       while (answer.hasMore()) { 
         SearchResult sr = (SearchResult)answer.next(); 
         System.out.println(">>>" + sr.getName()); 
       } 

我有錯誤:Failed to bind to LDAP [LDAP: error code 1 - 000020D6: SvcErr: DSID-03100754, problem 5012 (DIR_ERROR), data 0 remaining name 'ou=Users'

我怎麼能知道哪個名字命名的公司使用後ou=....

非常感謝把!

回答

3

您可以使用ldap瀏覽器來瀏覽ldap。 (我通常使用softerra Ldap管理員) 您需要連接的所有信息都在代碼的第一行(地址,端口等...)中