Hi,
I have the code snippet but it does not seem to work, could anyone point me out what wrong with it?
//try to remove a local user from a local group
string path = string.Format("WinNT://{0}/{1}/{2},group", domainName, serverName, groupName);
// Bind to remote computer Administrator group.
using (DirectoryEntry groupEntry = new DirectoryEntry(path))
{
path = string.Format("WinNT://{0}/{1}/{2},user", domainName, serverName, userName);
using (DirectoryEntry userEntry = new DirectoryEntry(path))
{
groupEntry.Children.Remove(userEntry);
}
}
I also find out that I could not cast the groupEntry to IADsgroup
string path = string.Format("WinNT://{0}/{1}/{2},group", domainName, serverName, groupName);
// Bind to remote computer Administrator group.
using (DirectoryEntry groupEntry = new DirectoryEntry(path))
{
IADsgroup grp = groupEntry as IADsgroup; //??? why the groupEntry cannot be cast to IADsgroup?
}
How can I add a domain group into a local group?
Thanks!
John