|
-
September 11th, 2006, 11:02 AM
#1
Renaming the Administrator Account, programatically, in win 2k, no AD
Hi all,
I'm trying to rename the administrator account in win2k, with no active directory... programaticaly.
basicaly they want an appp that does a bunch of stuff to bring computers up to snuff, security wise...
I got it working in xp thusly...
{
string AccountName = GetAdministratorAccountName();
string newNameForAccount = "Administrator";
ManagementObject theInstance = new ManagementObject( "root\\CIMv2", "Win32_UserAccount.Domain='" + Environment.MachineName + "',Name='" + AccountName + "'", null );
ManagementBaseObject inputParams = theInstance.GetMethodParameters( "Rename" );
inputParams.SetPropertyValue( "Name", newNameForAccount );
ManagementBaseObject outParams = theInstance.InvokeMethod( "Rename", inputParams, null );
}
but it does not work on win2k machines... I've followed several leads.. but no joy...
Can anyone point me towards a mechanism that will allow me to rename the administrator account on Win2k machines using c#?
Thanks,
Eric-
-
September 12th, 2006, 08:13 AM
#2
Re: Renaming the Administrator Account, programatically, in win 2k, no AD
I figured out how to do this using renuser.exe...
it's pretty simple the hardest part is findign a copy of renuser.exe.
I found it on the Korean verison of the english site that everyone links to.
http://www.ntfaq.co.kr/download/renuser.zip
Eric-
-
September 12th, 2006, 08:17 AM
#3
Re: Renaming the Administrator Account, programatically, in win 2k, no AD
If you can find the administrators account, you should be able to use System.DirectoryServices to rename it.
Code:
DirectoryEntry de = new DirectoryEntry( "WinNT://target_computer/admin_uid" );
de.Rename( "new_name" );
The call to the DirectoryServices object is specifying the use of the old NT4 ADSI calling convention - WinNT:.....so this forces it to look at the local machine.
I did not test this, but it may be a path to check.
HTH
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|