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

AddLogonAsServicePrivilege() public method

Add the privilege for the given account to logon as service.
public AddLogonAsServicePrivilege ( string account ) : void
account string The account name (domain\userName)
return void
        public void AddLogonAsServicePrivilege(string account)
        {
            AddPrivilege(account, "SeServiceLogonRight");
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Set the Log-On As Service privilege to the given user.
        /// </summary>
        /// <param name="userName">The account name (domain\name).</param>
        /// <returns>True for success; otherwise, false.</returns>
        public static bool SetLogonAsServicePrivilege(string userName)
        {
            try {
                using (LocalSecurityPolicy policy = new LocalSecurityPolicy()) {
                    policy.AddLogonAsServicePrivilege(userName);
                    return(true);
                }
            } catch { }

            return(false);
        }
All Usage Examples Of Opc.Ua.Configuration.LocalSecurityPolicy::AddLogonAsServicePrivilege