簡體   English   中英

使用Java進行LDAP認證,需要說明

[英]LDAP Authentication with Java, explanation needed

如果可以的話,請向我解釋一下我不太理解的以下代碼,我將不勝感激:

(&(cn=*)({0}={1}))在過濾器字段中是什么意思?

我知道cn表示搜索cn屬性,然后將結果添加到({0}={1})

({0}={1})是什么意思?

這是代碼:

try {
     // Create initial context
     ctx = new InitialDirContext(env);
     Attributes matchAttrs = new BasicAttributes(true);
     matchAttrs.put(new BasicAttribute(ldap_id_field, netid));

     String attlist[] = {ldap_email_field, ldap_givenname_field, 
            ldap_surname_field, ldap_phone_field};

    // look up attributes
      try {
      SearchControls ctls = new SearchControls();
     ctls.setReturningAttributes(attlist);
     NamingEnumeration answer = 
     ctx.search(ldap_search_context, "(&(cn=*)({0}={1}))", new Object[]  {ldap_id_field,netid},ctls);
     }
...

在我看來,這是錯誤的。 過濾器所做的只是在ldap_id_field和netid中查找具有任何CN且與指定為搜索參數的屬性名稱/值對匹配的條目。 沒有“添加”操作:&表示兩個filter-expressions必須匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM