简体   繁体   中英

Add group to the net user with c# code

I am working in asp.net with C#. I need to create ftp user with the code . i code for this requirement but new requirement is set diff diff folders for diff diff users .i think i need to create group and set groups to the user but i tried a lot but not getting any code for this requirement. Following is my current code that create a user for the ftp user.

 ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd.exe");
 procStartInfo.UseShellExecute = true;
 procStartInfo.CreateNoWindow = true;
 procStartInfo.Verb = "runas";
 procStartInfo.Arguments = "/env /user:" + "192.168.0.64/Administrator" + "cmd /K \"NET USER pky112 Admin123# /ADD    \"";

 procStartInfo.WindowStyle = ProcessWindowStyle.Normal;

 ///command contains the command to be executed in cmd
 System.Diagnostics.Process proc = new System.Diagnostics.Process();

 proc.StartInfo = procStartInfo;

 var sas=    proc.Start();

please suggest me new idea for this type of requirment

In order to set directory's security, use the following snippet:

DirectoryInfo directory = new DirectoryInfo(dirPath);
DirectorySecurity security = directory.GetAccessControl();
security.AddAccessRule(new FileSystemAccessRule({ftp server user\'s sddl}, FileSystemRights.FullControl, InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow));
directory.SetAccessControl(security);
directory.Refresh();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM