Search code examples
c#active-directorycomobject

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


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

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

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

I have tried to use :

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

The result is PropertyValueCollection

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


Solution

  • 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.