Re: ADSI and C#



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 :-)


"Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message
news:uGLKJdOTFHA.3392@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Victor Pereira" <taintmode@xxxxxxxxxxxx> wrote in message
> news:e7LHNTBTFHA.2336@xxxxxxxxxxxxxxxxxxxxxxx
> > Hi Marc,
> > I want to rename the logon name. Now i changed my approach and now i'm
> > using
> > WMI. But my problem is: This code does not work in W2k, just in XP and
> > 2003.
> > Do you know how can i do it in a W2k Enviroment ?
>
> You can't call Rename on W2K, it's only supported on XP, W2K and higher.
> Only thing you can do is delete and recreate the account using
> DirectoryServices with the WinNT provider. You are also aware of the
dangers
> of renaming the administrator account do you?
>
> Willy.
>
>


.



Relevant Pages

  • Re: Rename administrator account- Unattended from command line or
    ... Thanks for the tip Todd. ... I should have emphasized that I am trying to rename ... policy "rename administrator account" setting. ... "Administrator"--despite the fact that ADUC displayed the new admin name ...
    (microsoft.public.windows.server.general)
  • Re: Account Rename Policy
    ... Ok something changed in GPO leavethat one.But I don,t want to rename the ... Global administrator account policy,so tell me what i have to in GPO. ... TESTnamed DC and XYZ is a system is the member TEST domain. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Rename Administrator Account
    ... If you're ever in the mood to "change history" you can do this. ... and now you are going to have to go and scrape all ... the setting for 'rename administrator account' and 'rename ...
    (microsoft.public.windows.group_policy)
  • Re: Rename Administrator Account
    ... "Ageing Brilliantine Stick Insect" ... "Ageing Brilliantine Stick Insect" wrote: ... the setting for 'rename administrator account' and 'rename ...
    (microsoft.public.windows.group_policy)
  • Re: Admin Account Stalls on Client Desktops During Logon
    ... If you rename the administrator account to its original, ... > account to login to any client machine joined to the domain, ... I can of course still login to the Server and login ...
    (microsoft.public.backoffice.smallbiz2000)