using System;
using System.Data;
using System.DirectoryServices;
public class MainClass {
public static void Main(){
try{
DirectoryEntry directoryEntry1 = new DirectoryEntry();
DirectoryEntry directoryEntry2 = new DirectoryEntry();
directoryEntry1.AuthenticationType = System.DirectoryServices.AuthenticationTypes.Secure;
directoryEntry1.Path = "WinNT://MSHOME/alien";
directoryEntry2.Path = "WinNT://MSHOME/alien/Users";
DirectoryEntry newUser = directoryEntry1.Children.Add( "myUser", "User" );
newUser.Properties[ "FullName" ].Add( "myFullName" );
newUser.Properties[ "Description" ].Add( "myDescription" );
newUser.Invoke( "SetPassword", new object[] { "myPassword", } );
newUser.Properties[ "PasswordExpired" ].Add( 1 );
newUser.CommitChanges();
directoryEntry2.Invoke( "Add", new Object[] { newUser.Path, } );
directoryEntry2.CommitChanges();
Console.WriteLine(" added" );
}catch( Exception exc ) {
Console.WriteLine( exc.ToString() );
}
}
}