private static void RemoveAccountRight(IntPtr policyHandle, byte[] accountSid, string rightName)
        {
            NativeMethods.LSA_UNICODE_STRING accountRights = new NativeMethods.LSA_UNICODE_STRING();
            accountRights.buffer        = rightName;
            accountRights.length        = (short)(accountRights.buffer.Length * sizeof(char));
            accountRights.maximumLength = accountRights.length;
            int result = NativeMethods.LsaRemoveAccountRights(policyHandle, accountSid, false, accountRights, 1);

            if (result != 0)
            {
                throw new Win32Exception(SafeNativeMethods.LsaNtStatusToWinError(result));
            }
        }
        private static void RemoveAccountRight(IntPtr policyHandle, byte[] accountSid, string rightName)
        {
            NativeMethods.LSA_UNICODE_STRING lSA_UNICODE_STRING = new NativeMethods.LSA_UNICODE_STRING();
            lSA_UNICODE_STRING.buffer = rightName;
            NativeMethods.LSA_UNICODE_STRING lSA_UNICODE_STRING2 = lSA_UNICODE_STRING;
            lSA_UNICODE_STRING2.length = (short)(lSA_UNICODE_STRING2.buffer.Length * 2);
            NativeMethods.LSA_UNICODE_STRING lSA_UNICODE_STRING3 = lSA_UNICODE_STRING;
            lSA_UNICODE_STRING3.maximumLength = lSA_UNICODE_STRING3.length;
            int num = NativeMethods.LsaRemoveAccountRights(policyHandle, accountSid, false, lSA_UNICODE_STRING, 1);

            if (num == 0)
            {
                return;
            }
            throw new Win32Exception(SafeNativeMethods.LsaNtStatusToWinError(num));
        }
示例#3
0
 public static extern int LsaRemoveAccountRights(IntPtr policyHandle, byte[] accountSid, bool allRights, NativeMethods.LSA_UNICODE_STRING userRights, int countOfRights);
示例#4
0
 public static extern int LsaOpenPolicy(NativeMethods.LSA_UNICODE_STRING systemName, IntPtr pointerObjectAttributes,
                                        int desiredAccess, out IntPtr pointerPolicyHandle);