示例#1
0
        internal static void ToExtendedProtectedFromDeletion(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo)
        {
            ADObject aDObject = directoryObj as ADObject;

            if (aDObject == null)
            {
                object[] type = new object[2];
                type[0] = "ToExtendedProtectedFromDeletion";
                type[1] = directoryObj.GetType();
                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type));
            }
            else
            {
                userObj.Add(extendedAttribute, ProtectedFromDeletionUtil.IsProtectedFromDeletion(aDObject, cmdletSessionInfo));
                return;
            }
        }
示例#2
0
        private bool ADTargetScopeEnumerationServerPreProcessTargetCSRoutine()
        {
            object        baseObject;
            ADSessionInfo sessionInfo = this.GetSessionInfo();
            string        item        = this._cmdletParameters["Server"] as string;

            object[] objArray = this._cmdletParameters["Target"] as object[];
            for (int i = 0; i < (int)objArray.Length; i++)
            {
                object obj = objArray[i];
                if (obj as PSObject == null)
                {
                    baseObject = obj;
                }
                else
                {
                    baseObject = ((PSObject)obj).BaseObject;
                }
                string   str      = baseObject as string;
                ADEntity aDEntity = baseObject as ADEntity;
                if (aDEntity == null)
                {
                    ADScopeType?nullable       = (ADScopeType?)(this._cmdletParameters["Scope"] as ADScopeType?);
                    ADScopeType valueOrDefault = nullable.GetValueOrDefault();
                    if (nullable.HasValue)
                    {
                        switch (valueOrDefault)
                        {
                        case ADScopeType.Server:
                        {
                            this.AddSessionsMatchingServerName(str);
                            break;
                        }

                        case ADScopeType.Domain:
                        {
                            if (item == null)
                            {
                                ADDiscoverableService[] aDDiscoverableServiceArray = new ADDiscoverableService[1];
                                aDDiscoverableServiceArray[0] = ADDiscoverableService.ADWS;
                                ADMinimumDirectoryServiceVersion?nullable1 = null;
                                ADEntity aDEntity1 = DomainControllerUtil.DiscoverDomainController(null, str, aDDiscoverableServiceArray, ADDiscoverDomainControllerOptions.ReturnDnsName, nullable1);
                                this.SetPipelinedSessionInfo(new ADSessionInfo(aDEntity1["HostName"].Value as string));
                            }
                            ADDomainFactory <ADDomain> aDDomainFactory = new ADDomainFactory <ADDomain>();
                            aDDomainFactory.SetCmdletSessionInfo(this.GetCmdletSessionInfo());
                            ADDomain extendedObjectFromIdentity = aDDomainFactory.GetExtendedObjectFromIdentity(new ADDomain(str), this.GetRootDSE().DefaultNamingContext);
                            this.AddSessionsFromDomain(extendedObjectFromIdentity);
                            if (item != null)
                            {
                                break;
                            }
                            this.SetPipelinedSessionInfo(sessionInfo);
                            break;
                        }

                        case ADScopeType.Forest:
                        {
                            if (item != null)
                            {
                                ADForestFactory <ADForest> aDForestFactory = new ADForestFactory <ADForest>();
                                aDForestFactory.SetCmdletSessionInfo(this.GetCmdletSessionInfo());
                                try
                                {
                                    aDForestFactory.GetDirectoryObjectFromIdentity(new ADForest(str), null);
                                }
                                catch (ADIdentityNotFoundException aDIdentityNotFoundException1)
                                {
                                    ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1;
                                    base.WriteError(this.ConstructErrorRecord(aDIdentityNotFoundException));
                                    break;
                                }
                            }
                            else
                            {
                                ADDiscoverableService[] aDDiscoverableServiceArray1 = new ADDiscoverableService[1];
                                aDDiscoverableServiceArray1[0] = ADDiscoverableService.ADWS;
                                ADMinimumDirectoryServiceVersion?nullable2 = null;
                                ADEntity aDEntity2 = DomainControllerUtil.DiscoverDomainController(null, str, aDDiscoverableServiceArray1, ADDiscoverDomainControllerOptions.ReturnDnsName, nullable2);
                                this.SetPipelinedSessionInfo(new ADSessionInfo(aDEntity2["HostName"].Value as string));
                            }
                            this.AddSessionsFromConnectedForest();
                            if (item != null)
                            {
                                break;
                            }
                            this.SetPipelinedSessionInfo(sessionInfo);
                            break;
                        }

                        case ADScopeType.Site:
                        {
                            this.AddSessionsMatchingSiteName(str);
                            break;
                        }
                        }
                    }
                }
                else
                {
                    if (aDEntity.IsSearchResult)
                    {
                        this.SetPipelinedSessionInfo(aDEntity.SessionInfo);
                        if (aDEntity as ADForest == null)
                        {
                            if (aDEntity as ADDomain == null)
                            {
                                if (aDEntity as ADDirectoryServer == null)
                                {
                                    if (aDEntity as ADReplicationSite == null)
                                    {
                                        object[] type = new object[2];
                                        type[0] = aDEntity.GetType();
                                        type[1] = "Target";
                                        base.WriteErrorBuffered(this.ConstructErrorRecord(new ParameterBindingException(string.Format(CultureInfo.CurrentCulture, StringResources.UnsupportedParameterType, type))));
                                    }
                                    else
                                    {
                                        ADReplicationSite aDReplicationSite = (ADReplicationSite)aDEntity;
                                        this.AddSessionFromSiteDN(aDReplicationSite.DistinguishedName);
                                    }
                                }
                                else
                                {
                                    ADDirectoryServer aDDirectoryServer = (ADDirectoryServer)aDEntity;
                                    this._sessionPipe.AddLast(new ADSessionInfo(aDDirectoryServer["HostName"].Value as string));
                                }
                            }
                            else
                            {
                                ADDomain aDDomain = (ADDomain)aDEntity;
                                this.AddSessionsFromDomain(aDDomain);
                            }
                        }
                        else
                        {
                            this.AddSessionsFromConnectedForest();
                        }
                        this.SetPipelinedSessionInfo(sessionInfo);
                    }
                    else
                    {
                        base.WriteErrorBuffered(this.ConstructErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.OnlySearchResultsSupported, new object[0]))));
                    }
                }
            }
            return(true);
        }
示例#3
0
 private bool ADGetADTrustCmdletProcessInputObjectCSRoutine()
 {
     if (this._cmdletParameters.Contains("InputObject"))
     {
         object item = this._cmdletParameters["InputObject"];
         if (item as PSObject != null)
         {
             item = ((PSObject)item).BaseObject;
         }
         ADEntity aDEntity = item as ADEntity;
         string   str      = item as string;
         if (aDEntity == null)
         {
             if (str == null)
             {
                 object[] type = new object[2];
                 type[0] = item.GetType();
                 type[1] = "InputObject";
                 base.WriteErrorBuffered(this.ConstructErrorRecord(new ParameterBindingException(string.Format(CultureInfo.CurrentCulture, StringResources.UnsupportedParameterType, type))));
                 return(false);
             }
             else
             {
                 this._cmdletParameters["Identity"] = new ADTrust(str);
             }
         }
         else
         {
             if (aDEntity.IsSearchResult)
             {
                 if (aDEntity as ADForest != null || aDEntity as ADDomain != null || aDEntity as ADClaimTransformPolicy != null)
                 {
                     CmdletSessionInfo        cmdletSessionInfo      = this.GetCmdletSessionInfo();
                     ADTrustFactory <ADTrust> aDTrustFactory         = new ADTrustFactory <ADTrust>();
                     IADOPathNode             structuralObjectFilter = aDTrustFactory.StructuralObjectFilter;
                     if (aDEntity as ADForest != null || aDEntity as ADDomain != null)
                     {
                         if (!this._cmdletParameters.Contains("Server"))
                         {
                             ADSessionInfo aDSessionInfo = new ADSessionInfo(aDEntity["Name"].Value as string);
                             if (aDEntity as ADForest != null)
                             {
                                 aDSessionInfo.SetDefaultPort(LdapConstants.LDAP_GC_PORT);
                             }
                             if (cmdletSessionInfo.ADSessionInfo != null)
                             {
                                 aDSessionInfo.Credential = cmdletSessionInfo.ADSessionInfo.Credential;
                             }
                             cmdletSessionInfo.ADRootDSE     = null;
                             cmdletSessionInfo.ADSessionInfo = aDSessionInfo;
                             using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(aDSessionInfo))
                             {
                                 cmdletSessionInfo.ADRootDSE             = aDObjectSearcher.GetRootDSE();
                                 cmdletSessionInfo.ADRootDSE.SessionInfo = aDSessionInfo;
                             }
                             this.SetPipelinedSessionInfo(aDSessionInfo);
                         }
                         else
                         {
                             base.WriteErrorBuffered(this.ConstructErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ServerParameterNotSupported, new object[0]))));
                             return(false);
                         }
                     }
                     else
                     {
                         IADOPathNode   aDOPathNode      = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-EgressClaimsTransformationPolicy", aDEntity["DistinguishedName"].Value as string);
                         IADOPathNode   aDOPathNode1     = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-IngressClaimsTransformationPolicy", aDEntity["DistinguishedName"].Value as string);
                         IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
                         aDOPathNodeArray[0]    = aDOPathNode;
                         aDOPathNodeArray[1]    = aDOPathNode1;
                         structuralObjectFilter = ADOPathUtil.CreateOrClause(aDOPathNodeArray);
                     }
                     base.BuildPropertySet();
                     this._factory.SetCmdletSessionInfo(cmdletSessionInfo);
                     base.ValidateParameters();
                     base.OutputSearchResults(structuralObjectFilter);
                     return(false);
                 }
                 else
                 {
                     if (aDEntity as ADTrust == null)
                     {
                         if (string.Compare(this._factory.StructuralObjectClass, aDEntity["ObjectClass"].Value as string, StringComparison.OrdinalIgnoreCase) == 0)
                         {
                             this._cmdletParameters["Identity"] = new ADTrust((string)aDEntity["DistinguishedName"].Value);
                         }
                         else
                         {
                             object[] objArray = new object[2];
                             objArray[0] = aDEntity.GetType();
                             objArray[1] = "InputObject";
                             base.WriteErrorBuffered(this.ConstructErrorRecord(new ParameterBindingException(string.Format(CultureInfo.CurrentCulture, StringResources.UnsupportedParameterType, objArray))));
                             return(false);
                         }
                     }
                     else
                     {
                         this._cmdletParameters["Identity"] = (ADTrust)aDEntity;
                     }
                 }
             }
             else
             {
                 base.WriteErrorBuffered(this.ConstructErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.OnlySearchResultsSupported, new object[0]))));
                 return(false);
             }
         }
     }
     return(true);
 }