Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将计算机名添加到active directory组_C#_Sharepoint_Workflow_Workflow Activity - Fatal编程技术网

C# 将计算机名添加到active directory组

C# 将计算机名添加到active directory组,c#,sharepoint,workflow,workflow-activity,C#,Sharepoint,Workflow,Workflow Activity,我需要在预定义的active directory组中添加计算机名。有没有人有这方面的经验?您可以使用System.DirectoryServices通过C代码来完成这项工作 // Bind to the Computers container and add a new computer. DirectoryEntry de01 = new DirectoryEntry("LDAP://CN=Computers,DC=fabrikam,DC=com"); DirectoryEntry newCo

我需要在预定义的active directory组中添加计算机名。有没有人有这方面的经验?

您可以使用System.DirectoryServices通过C代码来完成这项工作

// Bind to the Computers container and add a new computer.
DirectoryEntry de01 = new DirectoryEntry("LDAP://CN=Computers,DC=fabrikam,DC=com");
DirectoryEntry newComputer = de01.Children.Add("CN=New Computer", "computer");
newGroup.CommitChanges();
有关示例,请参见。

您可以使用System.DirectoryServices通过C代码来完成此操作

// Bind to the Computers container and add a new computer.
DirectoryEntry de01 = new DirectoryEntry("LDAP://CN=Computers,DC=fabrikam,DC=com");
DirectoryEntry newComputer = de01.Children.Add("CN=New Computer", "computer");
newGroup.CommitChanges();

有关示例,请参见。

使用ADSI。基本上,您可以绑定到Active Directory,找到所需的计算机对象和组对象,并调用一个方法将计算机添加到组中

如果需要从命令行执行,可以使用WSH或.Net轻松地执行此操作

ADSI参考:

ADSI LDAP:


在计算机重新启动之前,它不会生效。

使用ADSI。基本上,您可以绑定到Active Directory,找到所需的计算机对象和组对象,并调用一个方法将计算机添加到组中

如果需要从命令行执行,可以使用WSH或.Net轻松地执行此操作

ADSI参考:

ADSI LDAP:


在计算机重新启动之前,它不会生效。

下面的代码对我有效

  //Step 1: get the DN of the adgroup you want to use
    DirectoryEntry groupEntry = new DirectoryEntry   ("LDAP://CN=AdgroupNameWewantToAddTo,DC=na,DC=ABCint,DC=com");//adgroupDSN
//步骤3:将PC添加到广告组
groupEntry.Invoke(“添加”,computerdn)


下面的代码对我有用

  //Step 1: get the DN of the adgroup you want to use
    DirectoryEntry groupEntry = new DirectoryEntry   ("LDAP://CN=AdgroupNameWewantToAddTo,DC=na,DC=ABCint,DC=com");//adgroupDSN
//步骤3:将PC添加到广告组
groupEntry.Invoke(“添加”,computerdn)


这对我不起作用,不知道为什么。它返回成功,但计算机未被添加。这对我不起作用。不知道为什么。它返回successful,但未添加计算机。