我能得到的Active Directory从属性的WindowsPrincipal? [英] Can I get Active Directory attributes from the WindowsPrincipal?
本文介绍了我能得到的Active Directory从属性的WindowsPrincipal?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得员工-ID为当前登录的用户。是在一些.NET类容易获得或做我需要做一些LDAP查询?
I would like to get the Employee-ID for the currently logged in user. Is that easily available in some .Net class or do I need to do some sort of LDAP query?
任何提示欢迎
推荐答案
甚至更简单 - 使用新的.NET 3.5 System.DirectoryServices.AccountManagement
功能。
Even easier - use the new .NET 3.5 System.DirectoryServices.AccountManagement
features.
请参阅MSDN文章在.NET Framework 3.5 管理目录安全主体一>有关详细信息。
See the MSDN article Managing Directory Security Principals in the .NET Framework 3.5 for details.
PrincipalContext ctx = new PrincipalContext(ContextType.Domain. "YOURDOMAIN");
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, loginName);
if(user != null)
{
string empID = user.EmployeeId;
}
新的强类型主要类使它成为一个微风与AD的工作。
The new strongly typed principal classes make it a breeze to work with AD.
这篇关于我能得到的Active Directory从属性的WindowsPrincipal?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文