Issue description
I am trying to create Active directory Users with my Program. All active directory related parts are working. What proves an Issue for me is the impersonation to create a folder on our file server and set the apropriate permissions. The issue with the impersonation is that multiple administrative accounts need to be used by the software. Hence it is not a solution to shift + rightclick -> run as different user
Task approach
So how I would handle it normally would include the following steps:
- Log in with an account with apropriate permissions on the home drive folder
- Navigate to '\FileServer\Data\Home'
- Create a folder for the user like '\FileServer\Data\Home\exampleuser1'
- Set the apropriate read/write permissions for that given user
Programmatically I would do something in the lines of (pseudocode):
string path = "\\FileServer\Data\Home\exampleuser1"
if (!Directory.Exists(path))
{
Directory.Create(path);
AddDirectorySecurity(path, @"MYDOMAIN\exampleuser1", FileSystemRights.TakeOwnership, AccessControlType.Allow);
}
however, this code would have to be executed with another user account "domain\admin_julian"