Any help on this would be greatly appreciated!!!
I want to rename the cn attribute something like [highlight]billn[/highlight] to [highlight]williamn[/highlight]
===========================================
===========================================
When I try to update the cn attribute I'm getting The directory service cannot perform the requested operation on the RDN attribute of an object error.
Does this mean that I cannot assign this value but rather drop the Member and add a new one? Seems like I'm missing something here.
TIA,
Rewdee
I want to rename the cn attribute something like [highlight]billn[/highlight] to [highlight]williamn[/highlight]
===========================================
Code:
private void RenameMember()
{
DirectoryEntry objUser;
if (String.Compare(NewUserName,User,true) != 0)
{
objUser = FindUser(User);
objUser.Properties["cn"].Value = NewUserName;
objUser.CommitChanges();
objUser.Close();
objUser.Dispose();
}
else throw new Exception("Cannot rename user as current user =" + User + " is the same as " + NewUserName);
}
public DirectoryEntry FindUser(string user)
{
DirectorySearcher ds = new DirectorySearcher(Base);
ds.Filter = "(&(objectCategory=Person)(objectClass=user)(cn=" + user + "))";
ds.SearchScope = SearchScope.Subtree;
SearchResult results = ds.FindOne();
if(results!=null)
{
DirectoryEntry de = new DirectoryEntry();
de = results.GetDirectoryEntry();
return de;
}
else return null;
}
When I try to update the cn attribute I'm getting The directory service cannot perform the requested operation on the RDN attribute of an object error.
Does this mean that I cannot assign this value but rather drop the Member and add a new one? Seems like I'm missing something here.
TIA,
Rewdee