Active Directory搜索成员资格的特定路径 [英] Active Directory Search specific path for membership
问题描述
我正在为某些应用程序实现AD身份验证。
我可以让身份验证工作,但我想获得用户所属的群组。我可以获得所有组的列表,但我想搜索特定的路径
i有我的ldap字符串:LDAP://192.168.XXX.XXX和我想要专门搜索以下组中的成员资格:OU =软件,DC = dom,DC =本地。
AD结构如下:
I''m implementing AD authentication for some applications.
I can get the authentication to work but i want to get what groups the user is apart of. I can get a list of ALL groups but i want to search a specific path
i have my ldap string: "LDAP://192.168.XXX.XXX" and i want to search specifically for memberships in the following group: "OU=Software,DC=dom,DC=local".
AD structure is as follows:
Root
-Software
-Developers
-Group 1
-Group 2
这样做的目的是创建访问权限控制基于他们所属的组。
The purpose of doing this is to create access control based on the groups they are a part of.
推荐答案
试试这个:
Try this:
// create context for domain
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find the user
UserPrincipal up = UserPrincipal.FindByIdentity(ctx, "YourUserName");
if(up != null)
{
// get groups for that user
var authGroups = up.GetAuthorizationGroups();
}
干杯,
Edo
Cheers,
Edo
这篇关于Active Directory搜索成员资格的特定路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!