Click here to Skip to main content
15,899,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I wrote a c# code that creates new local user

DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntry group = localMachine.Children.Find("administrators", "group");
DirectoryEntry user = localMachine.Children.Find(accountName, "user");
Console.WriteLine(user.Properties.ToString());


I tried to set the logon script for that user by doing:

localMachine.Properties["scriptPath"].Insert(0, "logonScript.vbs");             
localMachine.CommitChanges();


same with group or user instances.but the property doesn't exist in any of theses instances (localMachine, group or user). I know that because I did:

System.Collections.ICollection col = localMachine.Properties.PropertyNames;                
foreach (Object ob in col) {
        Console.WriteLine(ob.ToString());
} 


Any idea of how to do that in other way?
Cheers,
Posted
Updated 7-May-10 3:47am
v5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900