Retrieve sAMAccountName of users in LDAP group

时间:2018-06-04 16:47:17

标签: java spring security ldap spring-ldap

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!

1 个答案:

答案 0 :(得分:0)

由于LDAP服务器是Active Directory,您可以使用搜索过滤器中的memberOf属性来检索属于特定组的用户,并将返回属性设置为sAMAccountName。

(&(objectClass = user)(memberOf =“”))

请注意,这不是一种非常有效的方式。

相关问题