[英]How to set gecos attribute in Active Directory using directory services(C#)
I need to create an user in Active Directory using System.DirectoryServices
, and I can't figure how to set the gecos
attribute. 我需要使用
System.DirectoryServices
在Active Directory中创建一个用户,但无法确定如何设置gecos
属性。
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连接到LDAP,例如:
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 然后我可以轻松访问gecos属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.