Opc.Ua.Configuration.LocalSecurityPolicy.AddPrivilege C# (CSharp) Method

AddPrivilege() public method

Add privileges for the given account
public AddPrivilege ( string account, string privilege ) : void
account string The account name (domain\userName)
privilege string The name of the privilege to add
return void
        public void AddPrivilege(string account, string privilege)
        {
            IntPtr pSid = GetSIDInformation(account);
            LSA_UNICODE_STRING[] privileges = new LSA_UNICODE_STRING[1];
            privileges[0] = InitLsaString(privilege);
            long ret = LsaAddAccountRights(lsaHandle, pSid, privileges, 1);
            if (ret != 0)//ret = 0 Success
            {
                if (ret == STATUS_ACCESS_DENIED)
                    throw new UnauthorizedAccessException();
                if ((ret == STATUS_INSUFFICIENT_RESOURCES) || (ret == STATUS_NO_MEMORY))
                    throw new OutOfMemoryException();
                
                throw new Win32Exception((int)LsaNtStatusToWinError((int)ret));
            }
        }