Modify "managedBy" attribute - An Operations Error Occured

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);
}
}
}
 
B

Brian Desmond [MVP]

Ricky,

I don't think managedBy is a multivalued property. It's linked, though, so,
I'd just set it's value to the DN of the user, and then commit.

--
--
Brian Desmond
Windows Server MVP
(e-mail address removed)12.il.us

Http://www.briandesmond.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top