如何在 C# 中从 Active Directory 获取 System.__ComObject 值

How to get a System.__ComObject value from Active Directory in C#

经过长时间的搜索,我决定针对我的问题提出自己的问题。

我尝试在 Active Directory 中获取 属性 的值,但我总是得到 System.__ComObject.

correspondance += compte.Properties["ENTPersonDateNaissance"][0];

我试过使用:

 Microsoft.VisualBasic.Information.TypeName(compte.Properties["ENTPersonDateNaissance"]

结果是属性ValueCollection

但是不知道怎么取值?

事实上,变量 "compte" 是 DirectoryEntry 类型,我将其切换为 SearchResult,现在我可以通过 :

访问它的值
compte.Properties["ENTPersonDateNaissance"][0].ToString()

希望对你有所帮助