如何在activedirectory中获取所有用户和extention属性? [英] How to get all users and extentionattribute in activedirectory?
本文介绍了如何在activedirectory中获取所有用户和extention属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用
System.DirectoryServices.AccountManagement;
For one user i am using:
public UserPrincipal GetUser(string username)
{
PrincipalContext context = GetPrincipalContext();
UserPrincipal UserPrincipal =
UserPrincipal.FindByIdentity(context , sUserName);
return UserPrincipal;
}
其次,
我怎样才能得到特定用户的延伸价值如
extentionattribute9使用
secondly,
How can i get the extention attibute value of specific user like
extentionattribute9 by using
System.DirectoryServices.AccountManagement;
因为我得到的用户不包含上述功能中的扩展属性值。
我尝试过:
because the user i get does not contain the extention attributes value in above function.
What I have tried:
public UserPrincipal GetUser(string username)
{
PrincipalContext context = GetPrincipalContext();
UserPrincipal UserPrincipal =
UserPrincipal.FindByIdentity(context , sUserName);
return UserPrincipal;
}
推荐答案
这将为您提供所有活跃用户
foreach(UserPrincipal result in search.FindAll())
{
// if(result.EmailAddress!= null)
if (result.DisplayName!= null&& result.Enabled == true)
{
if(result.DistinguishedName!=CN =+ result.DisplayName +,OU =内部用户,DC = abcgroup,DC =内部&& result.Enabled == true)
userList.Add(result.DisplayName);
}
}
this will get you all active users
foreach (UserPrincipal result in search.FindAll())
{
//if (result.EmailAddress != null)
if (result.DisplayName != null && result.Enabled == true)
{
if (result.DistinguishedName != "CN=" + result.DisplayName + ",OU=Internal User,DC=abcgroup,DC=internal" && result.Enabled == true)
userList.Add(result.DisplayName);
}
}
这篇关于如何在activedirectory中获取所有用户和extention属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文