[英]LDAP Authentication with Java, explanation needed
if you could please explain to me one piece of the following code that I don't quite understand I would be grateful: 如果可以的话,请向我解释一下我不太理解的以下代码,我将不胜感激:
What does (&(cn=*)({0}={1}))
mean in the filter field? (&(cn=*)({0}={1}))
在过滤器字段中是什么意思?
I know that cn
means search for the cn
attribute and then ADD the result to ({0}={1})
. 我知道
cn
表示搜索cn
属性,然后将结果添加到({0}={1})
。
What is the meaning of ({0}={1})
? ({0}={1})
是什么意思?
Here's the code: 这是代码:
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);
}
...
It looks wrong to me. 在我看来,这是错误的。 All that filter does is find entries which have any CN and which match an attribute name/value pair specified as arguments to the search, in ldap_id_field and netid respectively.
过滤器所做的只是在ldap_id_field和netid中查找具有任何CN且与指定为搜索参数的属性名称/值对匹配的条目。 There is no 'adding' going on: the & means that both filter-expressions must match.
没有“添加”操作:&表示两个filter-expressions必须匹配。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.