public unsafe LsaPolicy(string systemName) { NativeMethods.LSA_UNICODE_STRING lsasSystemName = new NativeMethods.LSA_UNICODE_STRING(systemName); try { _lsaOpen(&lsasSystemName); } finally { lsasSystemName.Dispose(); } }
public unsafe void Reset(Sid sid, string userRight) { IntPtr psid = sid.AllocHGlobal(); NativeMethods.LSA_UNICODE_STRING lsasUserRight = new NativeMethods.LSA_UNICODE_STRING(userRight); try { UInt32 rtn = NativeMethods.LsaRemoveAccountRights(_policyHandle, psid, false, &lsasUserRight, 1); if (rtn != 0) { throw NativeMethods.NewSystemError("LsaRemoveAccountRights failed", NativeMethods.LsaNtStatusToWinError(rtn)); } } finally { lsasUserRight.Dispose(); Marshal.FreeHGlobal(psid); } }