Search code examples
c#windowsacl

In which cases DirectorySecurity.ModifyAccessRule returns false?


We found here the next snippet of code:

bool Result = false;
Security.ModifyAccessRule(AccessControlModification.Set, AccessRule, out Result);

if (!Result)
    return false;

In which exact cases "Result" is going to be false? Does anyone know? Please, help us.


Solution

  • According to the docs, the result of Security.ModifyAccessRule would be true if the DACL is successfully modified; otherwise, false

    See the following for reference:
    https://learn.microsoft.com/en-us/dotnet/api/system.security.accesscontrol.objectsecurity.modifyaccessrule?view=netframework-4.7.2