使用GroupPrincipal你能得到UserPrincipal更多信息 [英] using GroupPrincipal can you get additional info from UserPrincipal
本文介绍了使用GroupPrincipal你能得到UserPrincipal更多信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找了用户谁使用GroupPrincipal的AD组的成员。
I am looking up users who are members of an AD group using GroupPrincipal.
GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, "Advisors");
我需要从该查询得到的雇员场,但我相信使用UserPrincipal这仅仅是可能的。
I need to get the EmployeeID field from this lookup but I believe this is only possible using UserPrincipal.
var members = group.Members.Select(x => new DomainContext() { EmployeeID = x.EmployeeId, FullName = x.DisplayName }).ToList();
有谁知道的办法解决这?
Does anyone know of a way round this?
推荐答案
您已经除非你使用底层的DirectoryEntry / DirectorySearcher从类使用UserPrincipal。
You have to use UserPrincipal unless you're using the underlying DirectoryEntry/DirectorySearcher classes.
您应该使用.GetMembers代替.Members(),那么你可以做的东西,如:
You should use .GetMembers() instead of .Members then you can do stuff like:
var userMembers = group.GetMembers().OfType<UserPrincipal>();
foreach( var member in userMembers) {
string empid = member.EmployeeId; //do something with the EmployeeId
}
这篇关于使用GroupPrincipal你能得到UserPrincipal更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文