简体   繁体   English

检索 LDAP 组中用户的 sAMAccountName

[英]Retrieve sAMAccountName of users in LDAP group

I need to retrieve user_ids (sAMAccountName) of a list of users under a LDAP group.我需要检索 LDAP 组下用户列表的user_ids (sAMAccountName)。 I am using Spring security org.springframework.ldap.core.LdapTemplate with org.springframework.ldap.core.AttributesMapper implementation.我正在使用 Spring 安全org.springframework.ldap.core.LdapTemplateorg.springframework.ldap.core.AttributesMapper实现。

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) .我的搜索(属性成员)返回用户名(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.为了获得 sAMAccountName,我必须转身做另一个 LDAP 查找。

Is there a way I could get sAMAccountName of users using a single lookup?有没有一种方法可以使用单次查找获取用户的 sAMAccountName ?

Thank you!谢谢!

Since the LDAP server is an Active Directory you could make use of the memberOf attribute in the search filter to retrieve users belonging to a specific group and set returning attribute as sAMAccountName.由于 LDAP 服务器是一个 Active Directory,您可以使用搜索过滤器中的 memberOf 属性来检索属于特定组的用户并将返回属性设置为 sAMAccountName。

(&(objectClass=user)(memberOf="")) (&(objectClass=user)(memberOf=""))

Note that this is not a very efficient way.请注意,这不是一种非常有效的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM