Change the User´s FullName

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Victor Pereira

    #1

    Change the User´s FullName

    Hi i'm trying to change the user's fullname, so i wrote a function named
    ChangeFullName( string obj, string FullName)
    The first parameter is the user's object path (ex
    CN=User,OU=WTF, DC=Foo,DC=Bar) and the second parameter is the user's new
    name
    (ex Mr User Dinosaur Head). I'm recieving the following error: "The
    directory service cannot perform the requested operation on the RDN attribut
    e of an object." What's the problem ? I can't find any reference to this
    error..

    Here is the function:
    static void ChangeFullName( string obj, string FullName)

    {

    DirectoryEntry User = null;

    try

    {

    User = new DirectoryEntry( "LDAP://" + obj);

    DirectorySearch er search = new DirectorySearch er(User);

    search.Properti esToLoad.Add("c n");

    SearchResult result = search.FindOne( );

    if(result != null)

    {

    DirectoryEntry nEntry = result.GetDirec toryEntry();

    nEntry.Properti es["cn"].Value = FullName;

    nEntry.CommitCh anges();

    }

    }

    catch(System.Ru ntime.InteropSe rvices.COMExcep tion ez)

    {

    Console.WriteLi ne(ez.Message);

    return;

    }

    catch(Exception e)

    {

    Console.WriteLi ne(e.Message);

    return;

    }

    }



    Thanks in advance,



    Victor


Working...