如何从 LDAP 查询多个用户。
我正在使用 DirContext.search(基础、过滤器、范围);在我的java程序中
截至目前,它在使用单值过滤器时工作正常。过滤器=(“uid=名称”)
但我的要求是一次将多个名称传递给过滤器
filter=("uid=name1,name2,name3....") .
最佳答案
LDAP 对其过滤器使用“前缀”表示法。
例如:
或条件
(|(attr1=val1)(attr2=val2)(attr1=val2))
AND条件
(&(attr1=val1)(attr2=val2)(attr1=val2))
在您的情况下,过滤条件将是这样的:
filter = "(|(uid=name1)(uid=name2)(uid=name3))"
上面的过滤器意味着:
Find any user who has
uid=name1
ORuid=name2
ORuid=name3
.
这应该列出用户 ID 为 name1、name2 或 name3 的用户。
More Exmples:
Equality:
(attribute=abc)
, e.g. (&(objectclass=user)(displayName=JohnDoe))Negation:
(!(attribute=abc))
, e.g. (!objectClass=group)Presence:
(attribute=*)
, e.g. (mailNickName=*)Absence:
(!(attribute=*))
, e.g. (!proxyAddresses=*)Greater than:
(attribute>=abc)
, e.g. (storageQuota>=100000)Less than:
(attribute<=abc)
, e.g. (storageQuota<=100000)Proximity:
(attribute~=abc)
, e.g. (displayName~=JohnDoe)*(~= may not be compatible with all directory servers !!)
Wildcards: e.g. (sn=J*) or (mail=*@example.com) or (givenName=*John*)
希望这对您有所帮助!
关于java - 如何从 LDAP 查询多个用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42415694/