예제 #1
0
        protected override void BeginProcessing()
        {
            PswaAuthorizationRuleManager.Instance.TestRuleRuleMatch += new EventHandler <TestRuleRuleMatchEventArgs>(this.OnRuleMatch);
            PswaAuthorizationRuleManager instance = PswaAuthorizationRuleManager.Instance;

            instance.TestRuleInvalidRule += new EventHandler <TestRuleInvalidRuleEventArgs>(this.OnInvalidRule);
        }
예제 #2
0
        protected override void EndProcessing()
        {
            PswaAuthorizationRuleManager instance = PswaAuthorizationRuleManager.Instance;

            instance.GetRuleByIdNotFound -= new EventHandler <GetRuleByIdNotFoundEventArgs>(this.OnGetRuleByIdNotFound);
            PswaAuthorizationRuleManager pswaAuthorizationRuleManager = PswaAuthorizationRuleManager.Instance;

            pswaAuthorizationRuleManager.GetRuleByNameNotFound -= new EventHandler <GetRuleByNameNotFoundEventArgs>(this.OnGetRuleByNameNotFound);
        }
        protected override void BeginProcessing()
        {
            PswaAuthorizationRuleManager instance = PswaAuthorizationRuleManager.Instance;

            instance.GetRuleByIdNotFound += new EventHandler <GetRuleByIdNotFoundEventArgs>(this.OnGetRuleByIdNotFound);
        }
 static PswaAuthorizationRuleManager()
 {
     PswaAuthorizationRuleManager.instance = new PswaAuthorizationRuleManager();
 }
예제 #5
0
		static PswaAuthorizationRuleManager()
		{
			PswaAuthorizationRuleManager.instance = new PswaAuthorizationRuleManager();
		}
        protected override void ProcessRecord()
        {
            string       str;
            PswaUserType pswaUserType;
            bool         flag;
            bool         flag1;
            bool         flag2;

            string[]            userName            = new string[0];
            PswaUserType        pswaUserType1       = PswaUserType.User;
            string              empty               = string.Empty;
            PswaDestinationType pswaDestinationType = PswaDestinationType.Computer;

            if (base.ParameterSetName == "UserNameComputerName" || base.ParameterSetName == "UserNameComputerGroupName")
            {
                userName      = this.UserName;
                pswaUserType1 = PswaUserType.User;
                for (int i = 0; i < (int)userName.Length; i++)
                {
                    userName[i] = PswaHelper.TranslateLocalAccountName(userName[i]);
                }
            }
            else
            {
                if (base.ParameterSetName == "UserGroupNameComputerName" || base.ParameterSetName == "UserGroupNameComputerGroupName")
                {
                    userName      = this.UserGroupName;
                    pswaUserType1 = PswaUserType.UserGroup;
                    for (int j = 0; j < (int)userName.Length; j++)
                    {
                        userName[j] = PswaHelper.TranslateLocalAccountName(userName[j]);
                    }
                }
            }
            if (base.ParameterSetName == "UserNameComputerName" || base.ParameterSetName == "UserGroupNameComputerName")
            {
                empty = this.ComputerName;
                pswaDestinationType = PswaDestinationType.Computer;
            }
            else
            {
                if (base.ParameterSetName == "UserNameComputerGroupName" || base.ParameterSetName == "UserGroupNameComputerGroupName")
                {
                    empty = PswaHelper.TranslateLocalAccountName(this.ComputerGroupName);
                    pswaDestinationType = PswaDestinationType.ComputerGroup;
                }
            }
            if (empty == "*")
            {
                pswaDestinationType = PswaDestinationType.All;
            }
            SortedList <int, PswaAuthorizationRule> nums = PswaAuthorizationRuleCommandHelper.LoadFromFile(this, "Add");

            if (nums != null)
            {
                str = null;
                try
                {
                    if (pswaDestinationType == PswaDestinationType.Computer)
                    {
                        string str1 = PswaAuthorizationRuleManager.Instance.TryParseDestinationIpAddress(empty);
                        if (str1 == null)
                        {
                            if (!PswaAuthorizationRuleManager.Instance.IsCurrentComputerDomainJoined())
                            {
                                str = empty;
                            }
                            else
                            {
                                string str2 = null;
                                PswaAuthorizationRuleManager.Instance.GetComputerFqdnAndSid(empty, out str2, out str);
                                if (str != null)
                                {
                                    if (string.Compare(str2, empty, StringComparison.OrdinalIgnoreCase) != 0)
                                    {
                                        if (this.Force)
                                        {
                                            flag = true;
                                        }
                                        else
                                        {
                                            object[] objArray = new object[1];
                                            objArray[0] = str2;
                                            flag        = base.ShouldContinue(string.Format(CultureInfo.CurrentCulture, Resources.AuthorizationRule_UseFqdnQuery, objArray), "");
                                        }
                                        bool flag3 = flag;
                                        if (flag3)
                                        {
                                            empty = str2;
                                        }
                                        else
                                        {
                                            return;
                                        }
                                    }
                                }
                                else
                                {
                                    if (this.Force)
                                    {
                                        flag1 = true;
                                    }
                                    else
                                    {
                                        object[] objArray1 = new object[1];
                                        objArray1[0] = empty;
                                        flag1        = base.ShouldContinue(string.Format(CultureInfo.CurrentCulture, Resources.AuthorizationRule_ForceComputerNameQuery, objArray1), "");
                                    }
                                    bool flag4 = flag1;
                                    if (flag4)
                                    {
                                        str = empty;
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                        else
                        {
                            empty = str1;
                            if (this.Force)
                            {
                                flag2 = true;
                            }
                            else
                            {
                                object[] objArray2 = new object[1];
                                objArray2[0] = empty;
                                flag2        = base.ShouldContinue(string.Format(CultureInfo.CurrentCulture, Resources.AuthorizationRule_UseIpAddressQuery, objArray2), "");
                            }
                            bool flag5 = flag2;
                            if (flag5)
                            {
                                str = empty;
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                    goto Label0;
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    base.WriteError(new ErrorRecord(exception, "AddRuleError", ErrorCategory.InvalidOperation, null));
                }
                return;
            }
            else
            {
                return;
            }
Label0:
            ArrayList arrayLists = new ArrayList();

            string[] strArrays = userName;
            int      num       = 0;

            while (num < (int)strArrays.Length)
            {
                string str3 = strArrays[num];
                try
                {
                    PswaAuthorizationRuleManager            instance = PswaAuthorizationRuleManager.Instance;
                    SortedList <int, PswaAuthorizationRule> nums1    = nums;
                    string ruleName = this.RuleName;
                    string str4     = str3;
                    if (str3 == "*")
                    {
                        pswaUserType = PswaUserType.All;
                    }
                    else
                    {
                        pswaUserType = pswaUserType1;
                    }
                    PswaAuthorizationRule pswaAuthorizationRule = instance.AddRule(nums1, ruleName, str4, pswaUserType, empty, pswaDestinationType, this.ConfigurationName, str);
                    arrayLists.Add(pswaAuthorizationRule);
                    if (arrayLists.Count >= this.batchAmount)
                    {
                        this.SaveCurrentBatch(nums, arrayLists);
                    }
                }
                catch (Exception exception3)
                {
                    Exception exception2 = exception3;
                    this.SaveCurrentBatch(nums, arrayLists);
                    base.WriteError(new ErrorRecord(exception2, "AddRuleError", ErrorCategory.InvalidOperation, null));
                }
                num++;
            }
            if (arrayLists.Count > 0)
            {
                this.SaveCurrentBatch(nums, arrayLists);
                return;
            }
            else
            {
                return;
            }
        }