Hello,
the correct order would be this:
1. Create the new user
2. Prepare a DirectorySecurity and populate it with the necessary entries
3. Call Directory.CreateDirectory(directory, security) to create the
directory with the security settings.
The first step is the tricky one and depends whether you want to create a
local user or a user in Actice Directory.
To create a local user, see
http://support.microsoft.com/default.aspx?scid=kb;en-us;306271
To create a user in AD, see
http://www.irishdev.com/blogs/jbrennan/archive/2005/02/01/455.aspx.
Once created you can use the NtAccount class to create your
DirectorySecurity:
NTAccount account = new NtAccount(username);
DirectorySecurity sec = new DirectorySecurity();
sec.SetAccessRule(new FileSystemRule(account, FileSystemRights.Read,
AccessControlType.Allow));
// Set the other necessary access rules
Directory.CreateDirectory(name, sec);
Greetings,
Henning Krause