tags:

views:

73

answers:

1

I've created a program in C# which creates users and adds them to groups, everything is working fine. But I also want to create a "home folder", which is on another server, and the share will be like this: 81file01/users/username. And of course set the rights of the folder to the newly created AD-user. Now we're using a vb-script to do this, and this part is done with Subinacl, but is there a way to do this through my c# code?

I'm using .net 3.5 by the way :)

A: 

You can shell out using System.Diagnostics.Process and just call Subinacl directly as you do now.

Or you roll your sleeves up, and get your hands dirty calling what appear to be mainly a Win32 set of APIs. The friendliest article on that subject I could find from Microsoft talks about using the COM interface via COM interop.

There are some wrappers to these APIs floating around, but how good they are, I don't know.

Steve Gilham
Thanks!I found an example:using System.Security.AccessControl;DirectoryInfo di = new DirectoryInfo(path); DirectorySecurity dSecurity = di.GetAccessControl(); FileSystemAccessRule rule = new FileSystemAccessRule("users", FileSystemRights.Modify , InheritanceFlags.None | InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, ControlType); dSecurity.SetAccessRule(rule); di.SetAccessControl(dSecurity);I'm trying this now, don't know if it will work though..
Svein Erik
And what about Powershell?I'm going to have to use Powershell later to create mailbox for the user as well...hmmmm
Svein Erik