Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
您可以使用 System.DirectoryServices 通过 C# 代码执行此操作,
请参阅 http://msdn.microsoft.com/en-us/library/ms180832(v=VS.90).aspx 例如。
You can do this through C# code using System.DirectoryServices
See http://msdn.microsoft.com/en-us/library/ms180832(v=VS.90).aspx for examples.
使用 ADSI。基本上,您绑定到 Active Directory,找到所需的计算机对象和组对象,然后调用方法将计算机添加到组中。
如果需要从命令行进行,您可以使用 WSH 或 .Net 轻松完成此操作。
ADSI 参考:
http://msdn.microsoft.com/en- us/library/aa772218(v=VS.85).aspx
ADSI LDAP:
http://msdn.microsoft.com/en- us/library/aa746384(v=VS.85).aspx
电脑重启后才会生效。
Use ADSI. Basically you bind to the Active Directory, locate the computer object and group object you need, and call a method to add the computer to the group.
If it needs to be from a command line, you can easily do this using WSH or .Net.
ADSI reference:
http://msdn.microsoft.com/en-us/library/aa772218(v=VS.85).aspx
ADSI LDAP:
http://msdn.microsoft.com/en-us/library/aa746384(v=VS.85).aspx
It will not take effect until the computer reboots.
下面的代码对我有用
Below code worked for me