System.Security.Principal.SecurityIdentifier sid = new System.Security.Principal.SecurityIdentifier(System.Security.Principal.WellKnownSidType.WorldSid, null);
System.Security.Principal.NTAccount acct = sid.Translate(typeof(System.Security.Principal.NTAccount)) as System.Security.Principal.NTAccount;
string strEveryoneAccount = acct.ToString();
DirectoryInfo dInfo = new DirectoryInfo(Environment.CurrentDirectory + "\\serverservice");
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(strEveryoneAccount, FileSystemRights.FullControl, AccessControlType.Allow));
dInfo.SetAccessControl(dSecurity);
No comments:
Post a Comment