I need to retrieve user_ids
(sAMAccountName) of a list of users under a LDAP group. I am using Spring security org.springframework.ldap.core.LdapTemplate
with org.springframework.ldap.core.AttributesMapper
implementation.
My search is:
template.search(base, filter, new AttributesMapperImpl());
My search (member of attribute) returns the name of the users
(CN=Lname\, Fname M,OU=xxx,OU=xxx,OU=Users,OU=xx,DC=xx,DC=xxxxx,DC=xx)
. In order to get the sAMAccountName I have to turn around do another LDAP lookup.
Is there a way I could get sAMAccountName of users using a single lookup?
Thank you!
答案 0 :(得分:0)
由于LDAP服务器是Active Directory,您可以使用搜索过滤器中的memberOf属性来检索属于特定组的用户,并将返回属性设置为sAMAccountName。
(&(objectClass = user)(memberOf =“”))
请注意,这不是一种非常有效的方式。