Re: ADSI and C#

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"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.


.



Relevant Pages

  • Re: ADSI and C#
    ... >> But when you sad that i must create and delete i think your wrong and ... > (that is a new SID) or do you need to keep the SID associated with a new ... > Note that someone who knows the SID of the original administrator, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ADSI and C#
    ... >> 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 ... >> Note that someone who knows the SID of the original administrator, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Breadbox vs C64c - reliability?
    ... games were compatible with the old SID, so with the new one you might ... the sad part is that during the 80's I had several different ... 64 variants ranging from the original breadbox to the 128D and my ... was anything different with the SID chip at that time. ...
    (comp.sys.cbm)