سؤال

I need to create an user in Active Directory using System.DirectoryServices, and I can't figure how to set the gecos attribute.

Trying this line simply won't work :

DEUtilisateur.Properties["gecos"].Value = gecosValue

I get the error :

The specified directory service attribute or value does not exist

Any tips on how to achieve this? Thank you

هل كانت مفيدة؟

المحلول

I finally found the way to access the attribute.

Instead of using directly the DirectoryEntry to connect to the LDAP such as :

DirectoryEntry DEBase = new DirectoryEntry("LDAP://" + DomaineName);

I used

DirectoryContext context = new DirectoryContext(DirectoryContextType.Domain, 
                    domaineName));

DirectoryEntry dERoot = System.DirectoryServices.ActiveDirectory.Domain.GetDomain(context).GetDirectoryEntry();

Then I have no problem accessing the gecos attribute

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top