Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是编程初学者,我想使用 C# 获取用户的 AD 组列表。如果您的答案很详细,它将更有帮助。
几个月前我已经这样做了,但手头没有代码。也许我可以稍后再查看,但这大致是它的工作原理:
UserPrincipal up = UserPrincipal.Current; foreach (GroupPrincipal gp in up.GetGroups()) { // do something with it, like reading out gp.Name }
希望能帮助到你。另外,添加System.DirectoryServices程序集
System.DirectoryServices