DirectoryEntry.Children 属性
使用此属性在层次结构中查找、检索或创建目录项。此属性是一个集合,它与通常的迭代功能一起,提供 Add 方法,通过该方法将节点直接添加到当前绑定到的父节点之下的集合。当向集合中添加节点时,必须指定新节点的名称以及要与该节点相关联的架构模板的名称。例如,您可能需要使用标题为“Computer”的架构在层次结构中添加新的计算机。
谁能给个此属性的ADD方法的详解呀?
如:
newEntry=entry.Children.Add(entryName,"user");
newEntry.UsePropertyCache=true;
newEntry.Properties["sAMAccountName"].Value="userName";
newEntry.Properties["userPrincipalName"].Value=="userName";
newEntry.Properties["sn"].Value="usetsn";
newEntry.Properties["displayName"].Value="userName";
newEntry.Properties["userAccountControl"].Value="66048";
newEntry.Properties["givenName"].Value="givename";
能针对每行进行注释下吗?
使用此属性在层次结构中查找、检索或创建目录项。此属性是一个集合,它与通常的迭代功能一起,提供 Add 方法,通过该方法将节点直接添加到当前绑定到的父节点之下的集合。当向集合中添加节点时,必须指定新节点的名称以及要与该节点相关联的架构模板的名称。例如,您可能需要使用标题为“Computer”的架构在层次结构中添加新的计算机。
谁能给个此属性的ADD方法的详解呀?
如:
newEntry=entry.Children.Add(entryName,"user");
newEntry.UsePropertyCache=true;
newEntry.Properties["sAMAccountName"].Value="userName";
newEntry.Properties["userPrincipalName"].Value=="userName";
newEntry.Properties["sn"].Value="usetsn";
newEntry.Properties["displayName"].Value="userName";
newEntry.Properties["userAccountControl"].Value="66048";
newEntry.Properties["givenName"].Value="givename";
能针对每行进行注释下吗?
解决方案 »
- 鼠标移动到form边框触发事件
- 怎么用打印出杨辉三角形啊
- C#串口控制脚踏开关采集视频图像
- socket 多线程ftp 无限等待的问题.有代码
- byte应用
- 如何在程序中实现把数据库脚本倒入数据库中??急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!急!
- -----------指点小弟一本学XML的好书,上一次买了一本垃圾书白白花了钱-------------
- 关于时间的问题!
- 初学C#: C#中的各种"对象"(变量)有作用域吗?某个对象在 { 中定义,出了 } 就会被回收吗?
- 请教异常处理的方法,在线等待。
- 如何创建XML文件
- rational rose 能生成 C# 2005代码吗
{
try
{
if (string.IsNullOrEmpty(userName))
throw new ArgumentNullException("userName", "Invalid User Name.");
if (string.IsNullOrEmpty(password))
throw new ArgumentNullException("password", "Invalid Password.");
DirectoryEntry directoryEntry = new DirectoryEntry("WinNT://" +
Environment.MachineName + ",computer");
bool userFound = false;
try
{
if (directoryEntry.Children.Find(userName, "user") != null)
userFound = true;
}
catch
{
userFound = false;
}
if (!userFound)
{
DirectoryEntry newUser = directoryEntry.Children.Add(userName, "user");
newUser.Invoke("SetPassword", new object[] { password });
newUser.Invoke("Put", new object[] { "Description", "Application Pool User Account" });
newUser.CommitChanges();
newUser.Close();
}
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
return true;
}
谁能给个此属性的ADD方法的详解呀?