如何从C#中的Active Directory获取System .__ ComObject值

如何从C#中的Active Directory获取System .__ ComObject值

问题描述:

经过长时间的搜索,我决定问自己有关问题的问题。

After a long period of search I decide to ask my own question about my problem.

我尝试获取Active Directory中某个属性的值,但是我总是得到 System .__ ComObject

I try to get the value of a Property in Active Directory, but I always get a System.__ComObject.

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

我尝试使用:

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

结果是 PropertyValueCollection

但是我不知道如何获得价值?

But I don't know how to get the value?

事实上,变量 compte的类型为DirectoryEntry,我将其切换为SearchResult,现在可以使用以下命令访问它的值:

In fact, the variable "compte" is of type DirectoryEntry, I switched it to SearchResult, and now I can access it value with :

compte.Properties["ENTPersonDateNaissance"][0].ToString()

我希望它能对您有所帮助。

I hope it can help.