Re: ADSI and C#
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Sat, 30 Apr 2005 10:30:21 +0200
"Victor Pereira" <taintmode@xxxxxxxxxxxx> wrote in message
news:%235kncyPTFHA.2996@xxxxxxxxxxxxxxxxxxxxxxx
> Hi Willy,
> Thanks for your reply.. two MVPs aswering my questions.. that is a honor!
>
> But when you sad that i must create and delete i think your wrong and here
> is a function to proof it!
>
> void RenameUser(string hostname,string admusr)
>
> {
>
> try
>
> {
>
> DirectoryEntry entry = new DirectoryEntry("WinNT://" + hostname +
> ",computer");
>
> DirectoryEntry cEntry = entry.Children.Find("administrator");
>
> MessageBox.Show(cEntry.Path.ToString());
>
> cEntry.MoveTo(entry,admusr);
>
> cEntry.CommitChanges();
>
> }
>
> catch(Exception cc)
>
> {
>
> MessageBox.Show(cc.Message.ToString());
>
> }
>
> }
>
>
>
> Reguards,
>
> Victor Pereira MVP-WannaBe :-)
>
Yes, but you probably know there are different ways to skin a cat, here is
another one.
DirectoryEntry cEntry = userEntry.Children.Find("administrator");
cEntry.Rename(admuser);
cEntry.CommitChanges();
All depends what you realy wanna do, do you need a completely new entry
(that is a new SID) or do you need to keep the SID associated with a new
name?.
Note that someone who knows the SID of the original administrator, can also
find the name of the new administrator when using MoveTo and Rename.
Willy.
.
- References:
- ADSI and C#
- From: Victor Pereira
- Re: ADSI and C#
- From: Marc Scheuner [MVP ADSI]
- Re: ADSI and C#
- From: Victor Pereira
- Re: ADSI and C#
- From: Willy Denoyette [MVP]
- Re: ADSI and C#
- From: Victor Pereira
- ADSI and C#
- Prev by Date: Re: Listening for an event
- Next by Date: The Right Collection for the Job
- Previous by thread: Re: ADSI and C#
- Next by thread: My Documents path in C#
- Index(es):
Relevant Pages
|