Example #1
0
        private bool SetADComputerServiceAccountBeginCSRoutine()
        {
            object item = this._cmdletParameters["ServiceAccount"];

            ADServiceAccount[] aDServiceAccountArray = item as ADServiceAccount[];
            if (aDServiceAccountArray == null)
            {
                ADServiceAccount aDServiceAccount = item as ADServiceAccount;
                if (aDServiceAccount != null)
                {
                    ADServiceAccount[] aDServiceAccountArray1 = new ADServiceAccount[1];
                    aDServiceAccountArray1[0] = aDServiceAccount;
                    aDServiceAccountArray     = aDServiceAccountArray1;
                }
            }
            if (aDServiceAccountArray == null)
            {
                ArgumentException argumentException = new ArgumentException(StringResources.ObjectNotFound);
                base.ThrowTerminatingError(new ErrorRecord(argumentException, "SetADComputerServiceAccount:BeginProcessingOverride", ErrorCategory.ObjectNotFound, this));
            }
            else
            {
                List <string>           strs = new List <string>();
                List <ADServiceAccount> aDServiceAccounts = new List <ADServiceAccount>();
                Hashtable hashtables = new Hashtable();
                ADServiceAccountFactory <ADServiceAccount> aDServiceAccountFactory = new ADServiceAccountFactory <ADServiceAccount>();
                ADServiceAccount[] aDServiceAccountArray2 = aDServiceAccountArray;
                for (int i = 0; i < (int)aDServiceAccountArray2.Length; i++)
                {
                    ADServiceAccount aDServiceAccount1 = aDServiceAccountArray2[i];
                    base.SetPipelinedSessionInfo(aDServiceAccount1.SessionInfo);
                    CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo();
                    aDServiceAccountFactory.SetCmdletSessionInfo(cmdletSessionInfo);
                    try
                    {
                        ADObject directoryObjectFromIdentity = aDServiceAccountFactory.GetDirectoryObjectFromIdentity(aDServiceAccount1, cmdletSessionInfo.DefaultPartitionPath);
                        strs.Add(directoryObjectFromIdentity.DistinguishedName);
                        this._resolvedServiceAccountList.Add(directoryObjectFromIdentity);
                    }
                    catch (ADIdentityNotFoundException aDIdentityNotFoundException1)
                    {
                        ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1;
                        DebugLogger.LogError("SetADComputerServiceAccount", aDIdentityNotFoundException.ToString());
                        aDServiceAccounts.Add(aDServiceAccount1);
                    }
                }
                if (aDServiceAccounts.Count > 0)
                {
                    ArgumentException argumentException1 = new ArgumentException(StringResources.ObjectNotFound);
                    base.ThrowTerminatingError(new ErrorRecord(argumentException1, "SetADComputerServiceAccount:BeginProcessingOverride", ErrorCategory.ObjectNotFound, aDServiceAccounts.ToArray()));
                }
                hashtables.Add(this._modifyOpString, strs.ToArray());
                this._cmdletParameters.RemoveParameter("ServiceAccount");
                this._cmdletParameters["ServiceAccount"] = new ADMultivalueHashtableParameter <string>(hashtables);
            }
            return(true);
        }
Example #2
0
 protected internal override string GenerateObjectClass(ADServiceAccountFactory <ADServiceAccount> factory, ADParameterSet cmdletParameters, NewADServiceAccountParameterSet dynamicParameters)
 {
     if (!cmdletParameters.GetSwitchParameterBooleanValue("RestrictToSingleComputer"))
     {
         return("msDS-GroupManagedServiceAccount");
     }
     else
     {
         return("msDS-ManagedServiceAccount");
     }
 }
 public ADServiceAccountCmdletBase(string cmdletVerb)
 {
     this._factory    = new ADServiceAccountFactory <ADServiceAccount>();
     this._cmdletVerb = cmdletVerb;
     base.ProcessRecordPipeline.InsertAtEnd(new CmdletSubroutine(this.ADServiceAccountCmdletBaseProcessCSRoutine));
 }