all groups > dotnet sdk > april 2008 >
You're in the

dotnet sdk

group:

Add User Profile to DirectoryEntry User?


Add User Profile to DirectoryEntry User? coconet
4/8/2008 3:41:10 PM
dotnet sdk:
I have the below code to make a new user. I would like to create a
user profile directory and populate it. This will be an automated user
for a Win32 service that will do things over the network so I want to
make sure the account can do everything a normal human can do. I
develop on Vista, co-worker develops on XP, and the end result will be
deployed on 2003 Server.

Thanks

string thispc = "WinNT://" + Environment.MachineName + ",computer";
DirectoryEntry dirRoot = new DirectoryEntry( thispc );
DirectoryEntries dirEntries = dirRoot.Children;
DirectoryEntry dirEntry = new DirectoryEntry();
DirectoryEntry newUser = dirEntries.Add( "myuser" , "user" );
newUser.Properties["FullName"].Add( "the user" );
newUser.Invoke( "SetPassword" , "mypassword" );
newUser.CommitChanges();

AddThis Social Bookmark Button