1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| DirectoryEntry computers = new DirectoryEntry(sLDAP + PCTarget, "Domain" + "\\" + "user", "Password", AuthenticationTypes.Secure);
computers.Options.SecurityMasks = SecurityMasks.Owner | SecurityMasks.Group | SecurityMasks.Dacl | SecurityMasks.Sacl;
try
{
ActiveDirectorySecurity sdc = computers.ObjectSecurity;
NTAccount Account = new NTAccount("Domain\\MyGroupName");
SecurityIdentifier Sid = (SecurityIdentifier)Account.Translate(typeof(SecurityIdentifier));
ActiveDirectoryAccessRule rule = new ActiveDirectoryAccessRule(Sid,ActiveDirectoryRights.ExtendedRight | ActiveDirectoryRights.GenericRead,AccessControlType.Allow);
//Le message apparaît ici lorsque SetAccessRule est exécuté !!!
sdc.SetAccessRule(rule);
computers.CommitChanges();
computers.Close();
computers.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
} |
Partager