如果您能向我解释以下一段我不太明白的代码,我将不胜感激:
过滤字段中的含义是什么(&(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);
}
...