示例#1
0
        public override DeploymentResult Execute()
        {
            //http://weblogs.asp.net/avnerk/archive/2007/05/10/granting-user-rights-in-c.aspx
            var result = new DeploymentResult();
            try
            {
                using (var lsa = new LsaWrapper())
                {
                    lsa.AddPrivileges(_userAccount, "SeBatchLogonRight");
                }
                LogSecurity("[security][lpo] Grant '{0}' LogOnAsBatch on '{1}'", _userAccount, _serverName);
            }
            catch (Win32Exception ex)
            {
                var sb = new StringBuilder();
                sb.AppendFormat("Error while attempting to grant '{0}' the right '{1}'", _userAccount,
                                "SeBatchLogonRight");
                result.AddError(sb.ToString(), ex);
            }

            return result;
        }
示例#2
0
        public override DeploymentResult Execute()
        {
            //http://weblogs.asp.net/avnerk/archive/2007/05/10/granting-user-rights-in-c.aspx
            var result = new DeploymentResult();

            try
            {
                using (var lsa = new LsaWrapper())
                {
                    lsa.AddPrivileges(_userAccount, "SeBatchLogonRight");
                }
                LogSecurity("[security][lpo] Grant '{0}' LogOnAsBatch on '{1}'", _userAccount, _serverName);
            }
            catch (Win32Exception ex)
            {
                var sb = new StringBuilder();
                sb.AppendFormat("Error while attempting to grant '{0}' the right '{1}'", _userAccount,
                                "SeBatchLogonRight");
                result.AddError(sb.ToString(), ex);
            }

            return(result);
        }