0
我想知道如何通过某个Web界面在IIS_USRS用户组下添加服务帐户用户。我需要提供它作为我的应用程序的一部分。以编程方式将用户添加到C#中的IIS_Usrs
环境 - IIS 6.0 +
感谢 阿米特·兰詹
我想知道如何通过某个Web界面在IIS_USRS用户组下添加服务帐户用户。我需要提供它作为我的应用程序的一部分。以编程方式将用户添加到C#中的IIS_Usrs
环境 - IIS 6.0 +
感谢 阿米特·兰詹
您可以通过添加引用 “System.DirectoryServices.dll程序” 然后你可以使用一个DirectoryEntry使用ADSI(Active Directory服务接口)像这样:
public static void AddUserToGroup(string userDistinguishedname, string groupDistinguishedName) {
DirectoryEntry group = new DirectoryEntry("LDAP://ldap.mydomain.com/" + groupDistinguishedName);
DirectoryEntry user = new DirectoryEntry("LDAP://ldap.mydomain.com/" + userDistinguishedname);
group.Username = "Administrator";
group.Password = "myAdminPassword";
using (group) //group is your DirectoryEntry for group
{
//member if your user DirectoryEntry
group.Invoke("Add", new string[] { user.Path });
}
}
希望这有助于