gpt4 book ai didi

.net - 使用 DirectoryServices.AccountManagement 访问姓名首字母字段

转载 作者:行者123 更新时间:2023-12-04 09:17:18 26 4
gpt4 key购买 nike

我是访问 Active Directory 的新手,有人建议我使用 System.DirectoryServices.AccountManagement但我找不到 initials变量有什么帮助吗?

最佳答案

您可以执行以下操作之一:

1) 您可以 延长 正常 UserPrincipal类以包含您经常需要的其他项目。这将是最干净的解决方案,真的。见 MSDN docs on extending the user principal , 或 answer to this SO question有关如何扩展 UserPrincipal 的示例具有附加属性的类

2)您可以“深入”到您的底层证券的深处DirectoryEntry并从那里获取数据:

    DirectoryEntry de = YourUserPrincipal.GetUnderlyingObject() as DirectoryEntry;

if(de != null)
{
var initials = de.Properties["initials"];

if(initials != null && initials.Count > 0)
{
string theInitials = de.Properties["initials"][0].ToString();
}
}

关于.net - 使用 DirectoryServices.AccountManagement 访问姓名首字母字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8472974/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com