I want to set some access rules to a file. Now when i set the rule, the variable name
contains the right username (like: domain\user).
string name = new SecurityIdentifier(rule.IdentityReference.Value).Translate(typeof(NTAccount)).ToString();
accessControl.AddAccessRule(rule);
But the next line throws a IdentityNotMappedException with the message:
Some or all identity references could not be translated.
why I can translate in the first line the IdentityReference to a username, but the second line can't translate it?
ok, I found this solution:
create the rule, and set the identityReferences
to this: new SecurityIdentifier(identity)