Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active Directory and RDN attributes???

Status
Not open for further replies.

rewdee

Programmer
Aug 17, 2001
295
0
0
US
Any help on this would be greatly appreciated!!!

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top