R
Ricky
I wanted to change the managedBy attribute for a group but
I keep on running on an operations error. Any help is
appreciated. Thanks!
This is the code for the method I'm using:
public static void SetGroupOwner(string Path, string User,
string Pwd, string Owner, string Group) {
DirectoryEntry ad =
GetDirectoryEntry("LDAP://server.domain.com", User, Pwd);
DirectorySearcher ds = new
DirectorySearcher(ad, string.Format("(&
(objectCategory=user)(name={0}))", Owner));
SearchResultCollection src =
ds.FindAll();
foreach(SearchResult sr in src)
{
try
{
DirectoryEntry usr = sr.GetDirectoryEntry();
DirectoryEntry de = GetDirectoryEntry(Group, User,
Pwd);
PropertyValueCollection pvc = de.Properties
["managedBy"];
pvc.Clear
();
pvc.Add
(GetProperty(usr, "distinguishedName"));
de.CommitChanges();
}
catch (Exception e) {
Console.WriteLine(e.Message);
}
}
}
I keep on running on an operations error. Any help is
appreciated. Thanks!
This is the code for the method I'm using:
public static void SetGroupOwner(string Path, string User,
string Pwd, string Owner, string Group) {
DirectoryEntry ad =
GetDirectoryEntry("LDAP://server.domain.com", User, Pwd);
DirectorySearcher ds = new
DirectorySearcher(ad, string.Format("(&
(objectCategory=user)(name={0}))", Owner));
SearchResultCollection src =
ds.FindAll();
foreach(SearchResult sr in src)
{
try
{
DirectoryEntry usr = sr.GetDirectoryEntry();
DirectoryEntry de = GetDirectoryEntry(Group, User,
Pwd);
PropertyValueCollection pvc = de.Properties
["managedBy"];
pvc.Clear
();
pvc.Add
(GetProperty(usr, "distinguishedName"));
de.CommitChanges();
}
catch (Exception e) {
Console.WriteLine(e.Message);
}
}
}