当前位置: 首页>>代码示例>>C#>>正文


C# DirectoryContext.isServer方法代码示例

本文整理汇总了C#中System.DirectoryServices.ActiveDirectory.DirectoryContext.isServer方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryContext.isServer方法的具体用法?C# DirectoryContext.isServer怎么用?C# DirectoryContext.isServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.DirectoryServices.ActiveDirectory.DirectoryContext的用法示例。


在下文中一共展示了DirectoryContext.isServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ActiveDirectorySchemaProperty

 public ActiveDirectorySchemaProperty(DirectoryContext context, string ldapDisplayName)
 {
     this.syntax = ~ActiveDirectorySyntax.CaseExactString;
     this.rangeLower = null;
     this.rangeUpper = null;
     this.linkId = null;
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if ((context.Name == null) && !context.isRootDomain())
     {
         throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context");
     }
     if (((context.Name != null) && !context.isRootDomain()) && (!context.isADAMConfigSet() && !context.isServer()))
     {
         throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
     }
     if (ldapDisplayName == null)
     {
         throw new ArgumentNullException("ldapDisplayName");
     }
     if (ldapDisplayName.Length == 0)
     {
         throw new ArgumentException(Res.GetString("EmptyStringParameter"), "ldapDisplayName");
     }
     this.context = new DirectoryContext(context);
     this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.SchemaNamingContext);
     this.schemaEntry.Bind(true);
     this.ldapDisplayName = ldapDisplayName;
     this.commonName = ldapDisplayName;
     this.isBound = false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:ActiveDirectorySchemaProperty.cs

示例2: ActiveDirectorySchemaClass

        public ActiveDirectorySchemaClass(DirectoryContext context, string ldapDisplayName)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if ((context.Name == null) && (!context.isRootDomain()))
            {
                throw new ArgumentException(Res.GetString(Res.ContextNotAssociatedWithDomain), "context");
            }

            if (context.Name != null)
            {
                // the target should be a valid forest name or a server
                if (!((context.isRootDomain()) || (context.isADAMConfigSet()) || (context.isServer())))
                {
                    throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context");
                }
            }

            if (ldapDisplayName == null)
            {
                throw new ArgumentNullException("ldapDisplayName");
            }

            if (ldapDisplayName.Length == 0)
            {
                throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "ldapDisplayName");
            }

            _context = new DirectoryContext(context);

            // validate the context 
            _schemaEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.SchemaNamingContext);
            _schemaEntry.Bind(true);

            _ldapDisplayName = ldapDisplayName;
            // the common name will default to the ldap display name
            _commonName = ldapDisplayName;

            // set the bind flag
            this.isBound = false;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:44,代码来源:ActiveDirectorySchemaClass.cs

示例3: GetSchema

 public static ActiveDirectorySchema GetSchema(DirectoryContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (((context.ContextType != DirectoryContextType.Forest) && (context.ContextType != DirectoryContextType.ConfigurationSet)) && (context.ContextType != DirectoryContextType.DirectoryServer))
     {
         throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
     }
     if ((context.Name == null) && !context.isRootDomain())
     {
         throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ContextNotAssociatedWithDomain"), typeof(ActiveDirectorySchema), null);
     }
     if (((context.Name != null) && !context.isRootDomain()) && (!context.isADAMConfigSet() && !context.isServer()))
     {
         if (context.ContextType == DirectoryContextType.Forest)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ForestNotFound"), typeof(ActiveDirectorySchema), context.Name);
         }
         if (context.ContextType == DirectoryContextType.ConfigurationSet)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ConfigSetNotFound"), typeof(ActiveDirectorySchema), context.Name);
         }
         throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ServerNotFound", new object[] { context.Name }), typeof(ActiveDirectorySchema), null);
     }
     context = new DirectoryContext(context);
     DirectoryEntryManager directoryEntryMgr = new DirectoryEntryManager(context);
     string distinguishedName = null;
     try
     {
         DirectoryEntry cachedDirectoryEntry = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
         if (context.isServer() && !Utils.CheckCapability(cachedDirectoryEntry, Capability.ActiveDirectoryOrADAM))
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ServerNotFound", new object[] { context.Name }), typeof(ActiveDirectorySchema), null);
         }
         distinguishedName = (string) PropertyManager.GetPropertyValue(context, cachedDirectoryEntry, PropertyManager.SchemaNamingContext);
     }
     catch (COMException exception)
     {
         if (exception.ErrorCode != -2147016646)
         {
             throw ExceptionHelper.GetExceptionFromCOMException(context, exception);
         }
         if (context.ContextType == DirectoryContextType.Forest)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ForestNotFound"), typeof(ActiveDirectorySchema), context.Name);
         }
         if (context.ContextType == DirectoryContextType.ConfigurationSet)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ConfigSetNotFound"), typeof(ActiveDirectorySchema), context.Name);
         }
         throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ServerNotFound", new object[] { context.Name }), typeof(ActiveDirectorySchema), null);
     }
     catch (ActiveDirectoryObjectNotFoundException)
     {
         if (context.ContextType == DirectoryContextType.ConfigurationSet)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ConfigSetNotFound"), typeof(ActiveDirectorySchema), context.Name);
         }
         throw;
     }
     return new ActiveDirectorySchema(context, distinguishedName, directoryEntryMgr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:64,代码来源:ActiveDirectorySchema.cs

示例4: FindByName

        public static ActiveDirectorySchemaClass FindByName(DirectoryContext context, string ldapDisplayName)
        {
            ActiveDirectorySchemaClass schemaClass = null;

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if ((context.Name == null) && (!context.isRootDomain()))
            {
                throw new ArgumentException(Res.GetString(Res.ContextNotAssociatedWithDomain), "context");
            }

            if (context.Name != null)
            {
                if (!(context.isRootDomain() || context.isServer() || context.isADAMConfigSet()))
                {
                    throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context");
                }
            }

            if (ldapDisplayName == null)
            {
                throw new ArgumentNullException("ldapDisplayName");
            }

            if (ldapDisplayName.Length == 0)
            {
                throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "ldapDisplayName");
            }

            //  work with copy of the context
            context = new DirectoryContext(context);

            // create a schema class 
            schemaClass = new ActiveDirectorySchemaClass(context, ldapDisplayName, (DirectoryEntry)null, null);

            return schemaClass;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:40,代码来源:ActiveDirectorySchemaClass.cs

示例5: GetForest

		public static Forest GetForest(DirectoryContext context)
		{
			string propertyValue = null;
			if (context != null)
			{
				if (context.ContextType == DirectoryContextType.Forest || context.ContextType == DirectoryContextType.DirectoryServer)
				{
					if (context.Name != null || context.isRootDomain())
					{
						if (context.Name == null || context.isRootDomain() || context.isServer())
						{
							context = new DirectoryContext(context);
							DirectoryEntryManager directoryEntryManager = new DirectoryEntryManager(context);
							try
							{
								DirectoryEntry cachedDirectoryEntry = directoryEntryManager.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
								if (!context.isServer() || Utils.CheckCapability(cachedDirectoryEntry, Capability.ActiveDirectory))
								{
									propertyValue = (string)PropertyManager.GetPropertyValue(context, cachedDirectoryEntry, PropertyManager.RootDomainNamingContext);
								}
								else
								{
									object[] name = new object[1];
									name[0] = context.Name;
									throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DCNotFound", name), typeof(Forest), null);
								}
							}
							catch (COMException cOMException1)
							{
								COMException cOMException = cOMException1;
								int errorCode = cOMException.ErrorCode;
								if (errorCode != -2147016646)
								{
									throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException);
								}
								else
								{
									if (context.ContextType != DirectoryContextType.Forest)
									{
										object[] objArray = new object[1];
										objArray[0] = context.Name;
										throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DCNotFound", objArray), typeof(Forest), null);
									}
									else
									{
										throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ForestNotFound"), typeof(Forest), context.Name);
									}
								}
							}
							return new Forest(context, Utils.GetDnsNameFromDN(propertyValue), directoryEntryManager);
						}
						else
						{
							if (context.ContextType != DirectoryContextType.Forest)
							{
								object[] name1 = new object[1];
								name1[0] = context.Name;
								throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DCNotFound", name1), typeof(Forest), null);
							}
							else
							{
								throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ForestNotFound"), typeof(Forest), context.Name);
							}
						}
					}
					else
					{
						throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ContextNotAssociatedWithDomain"), typeof(Forest), null);
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("TargetShouldBeServerORForest"), "context");
				}
			}
			else
			{
				throw new ArgumentNullException("context");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:80,代码来源:Forest.cs

示例6: ValidateArgument

		private static void ValidateArgument(DirectoryContext context, string siteName)
		{
			if (context != null)
			{
				if (context.Name != null || context.isRootDomain())
				{
					if (context.Name == null || context.isRootDomain() || context.isServer() || context.isADAMConfigSet())
					{
						if (siteName != null)
						{
							if (siteName.Length != 0)
							{
								return;
							}
							else
							{
								throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName");
							}
						}
						else
						{
							throw new ArgumentNullException("siteName");
						}
					}
					else
					{
						throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context");
				}
			}
			else
			{
				throw new ArgumentNullException("context");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:39,代码来源:ActiveDirectorySite.cs

示例7: FindByTransportType

		public static ActiveDirectoryInterSiteTransport FindByTransportType(DirectoryContext context, ActiveDirectoryTransportType transport)
		{
			DirectoryEntry directoryEntry;
			if (context != null)
			{
				if (context.Name != null || context.isRootDomain())
				{
					if (context.Name == null || context.isRootDomain() || context.isServer() || context.isADAMConfigSet())
					{
						if (transport < ActiveDirectoryTransportType.Rpc || transport > ActiveDirectoryTransportType.Smtp)
						{
							throw new InvalidEnumArgumentException("value", (int)transport, typeof(ActiveDirectoryTransportType));
						}
						else
						{
							context = new DirectoryContext(context);
							try
							{
								directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE);
								string propertyValue = (string)PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext);
								string str = string.Concat("CN=Inter-Site Transports,CN=Sites,", propertyValue);
								if (transport != ActiveDirectoryTransportType.Rpc)
								{
									str = string.Concat("CN=SMTP,", str);
								}
								else
								{
									str = string.Concat("CN=IP,", str);
								}
								directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, str);
							}
							catch (COMException cOMException1)
							{
								COMException cOMException = cOMException1;
								throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException);
							}
							catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
							{
								object[] name = new object[1];
								name[0] = context.Name;
								throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", name));
							}
							try
							{
								string[] strArrays = new string[1];
								strArrays[0] = "options";
								directoryEntry.RefreshCache(strArrays);
							}
							catch (COMException cOMException3)
							{
								COMException cOMException2 = cOMException3;
								if (cOMException2.ErrorCode != -2147016656)
								{
									throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2);
								}
								else
								{
									DirectoryEntry directoryEntry1 = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE);
									if (!Utils.CheckCapability(directoryEntry1, Capability.ActiveDirectoryApplicationMode) || transport != ActiveDirectoryTransportType.Smtp)
									{
										object[] objArray = new object[1];
										objArray[0] = transport.ToString();
										throw new ActiveDirectoryObjectNotFoundException(Res.GetString("TransportNotFound", objArray), typeof(ActiveDirectoryInterSiteTransport), transport.ToString());
									}
									else
									{
										throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP"));
									}
								}
							}
							return new ActiveDirectoryInterSiteTransport(context, transport, directoryEntry);
						}
					}
					else
					{
						throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context");
				}
			}
			else
			{
				throw new ArgumentNullException("context");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:88,代码来源:ActiveDirectoryInterSiteTransport.cs

示例8: GetDomain

        public static Domain GetDomain(DirectoryContext context)
        {
            // check that the argument is not null
            if (context == null)
                throw new ArgumentNullException("context");

            // contexttype should be Domain or DirectoryServer
            if ((context.ContextType != DirectoryContextType.Domain) &&
                (context.ContextType != DirectoryContextType.DirectoryServer))
            {
                throw new ArgumentException(Res.GetString(Res.TargetShouldBeServerORDomain), "context");
            }

            if ((context.Name == null) && (!context.isDomain()))
            {
                throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ContextNotAssociatedWithDomain), typeof(Domain), null);
            }

            if (context.Name != null)
            {
                // the target should be a valid domain name or a server
                if (!((context.isDomain()) || (context.isServer())))
                {
                    if (context.ContextType == DirectoryContextType.Domain)
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DomainNotFound), typeof(Domain), context.Name);
                    }
                    else
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DCNotFound, context.Name), typeof(Domain), null);
                    }
                }
            }

            //  work with copy of the context
            context = new DirectoryContext(context);

            // bind to the rootDSE of the domain specified in the context
            // and get the dns name
            DirectoryEntryManager directoryEntryMgr = new DirectoryEntryManager(context);
            DirectoryEntry rootDSE = null;
            string defaultDomainNC = null;
            try
            {
                rootDSE = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
                if ((context.isServer()) && (!Utils.CheckCapability(rootDSE, Capability.ActiveDirectory)))
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DCNotFound, context.Name), typeof(Domain), null);
                }
                defaultDomainNC = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.DefaultNamingContext);
            }
            catch (COMException e)
            {
                int errorCode = e.ErrorCode;

                if (errorCode == unchecked((int)0x8007203a))
                {
                    if (context.ContextType == DirectoryContextType.Domain)
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DomainNotFound), typeof(Domain), context.Name);
                    }
                    else
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DCNotFound, context.Name), typeof(Domain), null);
                    }
                }
                else
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                }
            }

            // return domain object
            return new Domain(context, Utils.GetDnsNameFromDN(defaultDomainNC), directoryEntryMgr);
        }
开发者ID:chcosta,项目名称:corefx,代码行数:75,代码来源:Domain.cs

示例9: FindByName

		public static ActiveDirectorySchemaProperty FindByName(DirectoryContext context, string ldapDisplayName)
		{
			if (context != null)
			{
				if (context.Name != null || context.isRootDomain())
				{
					if (context.Name == null || context.isRootDomain() || context.isADAMConfigSet() || context.isServer())
					{
						if (ldapDisplayName != null)
						{
							if (ldapDisplayName.Length != 0)
							{
								context = new DirectoryContext(context);
								ActiveDirectorySchemaProperty activeDirectorySchemaProperty = new ActiveDirectorySchemaProperty(context, ldapDisplayName, (DirectoryEntry)null, (DirectoryEntry)null);
								return activeDirectorySchemaProperty;
							}
							else
							{
								throw new ArgumentException(Res.GetString("EmptyStringParameter"), "ldapDisplayName");
							}
						}
						else
						{
							throw new ArgumentNullException("ldapDisplayName");
						}
					}
					else
					{
						throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context");
				}
			}
			else
			{
				throw new ArgumentNullException("context");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:41,代码来源:ActiveDirectorySchemaProperty.cs

示例10: ActiveDirectorySchemaProperty

		public ActiveDirectorySchemaProperty(DirectoryContext context, string ldapDisplayName)
		{
			this.syntax = ActiveDirectorySyntax.CaseIgnoreString | ActiveDirectorySyntax.NumericString | ActiveDirectorySyntax.DirectoryString | ActiveDirectorySyntax.OctetString | ActiveDirectorySyntax.SecurityDescriptor | ActiveDirectorySyntax.Int | ActiveDirectorySyntax.Int64 | ActiveDirectorySyntax.Bool | ActiveDirectorySyntax.Oid | ActiveDirectorySyntax.GeneralizedTime | ActiveDirectorySyntax.UtcTime | ActiveDirectorySyntax.DN | ActiveDirectorySyntax.DNWithBinary | ActiveDirectorySyntax.DNWithString | ActiveDirectorySyntax.Enumeration | ActiveDirectorySyntax.IA5String | ActiveDirectorySyntax.PrintableString | ActiveDirectorySyntax.Sid | ActiveDirectorySyntax.AccessPointDN | ActiveDirectorySyntax.ORName | ActiveDirectorySyntax.PresentationAddress | ActiveDirectorySyntax.ReplicaLink;
			this.rangeLower = null;
			this.rangeUpper = null;
			this.linkId = null;
			if (context != null)
			{
				if (context.Name != null || context.isRootDomain())
				{
					if (context.Name == null || context.isRootDomain() || context.isADAMConfigSet() || context.isServer())
					{
						if (ldapDisplayName != null)
						{
							if (ldapDisplayName.Length != 0)
							{
								this.context = new DirectoryContext(context);
								this.schemaEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.SchemaNamingContext);
								//TODO: REVIEW: URGENT!!:this.schemaEntry.Bind(true);
								this.ldapDisplayName = ldapDisplayName;
								this.commonName = ldapDisplayName;
								this.isBound = false;
								return;
							}
							else
							{
								throw new ArgumentException(Res.GetString("EmptyStringParameter"), "ldapDisplayName");
							}
						}
						else
						{
							throw new ArgumentNullException("ldapDisplayName");
						}
					}
					else
					{
						throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context");
				}
			}
			else
			{
				throw new ArgumentNullException("context");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:49,代码来源:ActiveDirectorySchemaProperty.cs

示例11: FindByName

        public static ActiveDirectorySchemaProperty FindByName(DirectoryContext context, string ldapDisplayName)
        {
            ActiveDirectorySchemaProperty schemaProperty = null;

            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if ((context.Name == null) && (!context.isRootDomain()))
            {
                throw new ArgumentException(Res.GetString(Res.ContextNotAssociatedWithDomain), "context");
            }

            if (context.Name != null)
            {
                // the target should be a valid forest name or a server
                if (!((context.isRootDomain()) || (context.isADAMConfigSet()) || (context.isServer())))
                {
                    throw new ArgumentException(Res.GetString(Res.NotADOrADAM), "context");
                }
            }

            if (ldapDisplayName == null)
            {
                throw new ArgumentNullException("ldapDisplayName");
            }

            if (ldapDisplayName.Length == 0)
            {
                throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "ldapDisplayName");
            }

            //  work with copy of the context
            context = new DirectoryContext(context);

            // create a schema property 
            schemaProperty = new ActiveDirectorySchemaProperty(context, ldapDisplayName, (DirectoryEntry)null, null);

            return schemaProperty;
        }
开发者ID:chcosta,项目名称:corefx,代码行数:41,代码来源:ActiveDirectorySchemaProperty.cs

示例12: GetAdamInstance

 public static AdamInstance GetAdamInstance(DirectoryContext context)
 {
     DirectoryEntryManager directoryEntryMgr = null;
     string adamHostName = null;
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (context.ContextType != DirectoryContextType.DirectoryServer)
     {
         throw new ArgumentException(Res.GetString("TargetShouldBeADAMServer"), "context");
     }
     if (!context.isServer())
     {
         throw new ActiveDirectoryObjectNotFoundException(Res.GetString("AINotFound", new object[] { context.Name }), typeof(AdamInstance), context.Name);
     }
     context = new DirectoryContext(context);
     try
     {
         directoryEntryMgr = new DirectoryEntryManager(context);
         DirectoryEntry cachedDirectoryEntry = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
         if (!Utils.CheckCapability(cachedDirectoryEntry, Capability.ActiveDirectoryApplicationMode))
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("AINotFound", new object[] { context.Name }), typeof(AdamInstance), context.Name);
         }
         adamHostName = (string) PropertyManager.GetPropertyValue(context, cachedDirectoryEntry, PropertyManager.DnsHostName);
     }
     catch (COMException exception)
     {
         if (exception.ErrorCode == -2147016646)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("AINotFound", new object[] { context.Name }), typeof(AdamInstance), context.Name);
         }
         throw System.DirectoryServices.ActiveDirectory.ExceptionHelper.GetExceptionFromCOMException(context, exception);
     }
     return new AdamInstance(context, adamHostName, directoryEntryMgr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:37,代码来源:AdamInstance.cs

示例13: ValidateArgument

        private static void ValidateArgument(DirectoryContext context, string name)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            // the target of the scope must be server
            if (context.Name == null || !context.isServer())
                throw new ArgumentException(Res.GetString(Res.DirectoryContextNeedHost));

            if (name == null)
                throw new ArgumentNullException("name");

            if (name.Length == 0)
                throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "name");
        }
开发者ID:chcosta,项目名称:corefx,代码行数:15,代码来源:ReplicationConnection.cs

示例14: FindByTransportType

 public static ActiveDirectoryInterSiteTransport FindByTransportType(DirectoryContext context, ActiveDirectoryTransportType transport)
 {
     DirectoryEntry directoryEntry;
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if ((context.Name == null) && !context.isRootDomain())
     {
         throw new ArgumentException(Res.GetString("ContextNotAssociatedWithDomain"), "context");
     }
     if (((context.Name != null) && !context.isRootDomain()) && (!context.isServer() && !context.isADAMConfigSet()))
     {
         throw new ArgumentException(Res.GetString("NotADOrADAM"), "context");
     }
     if ((transport < ActiveDirectoryTransportType.Rpc) || (transport > ActiveDirectoryTransportType.Smtp))
     {
         throw new InvalidEnumArgumentException("value", (int) transport, typeof(ActiveDirectoryTransportType));
     }
     context = new DirectoryContext(context);
     try
     {
         directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE);
         string str = (string) PropertyManager.GetPropertyValue(context, directoryEntry, PropertyManager.ConfigurationNamingContext);
         string dn = "CN=Inter-Site Transports,CN=Sites," + str;
         if (transport == ActiveDirectoryTransportType.Rpc)
         {
             dn = "CN=IP," + dn;
         }
         else
         {
             dn = "CN=SMTP," + dn;
         }
         directoryEntry = DirectoryEntryManager.GetDirectoryEntry(context, dn);
     }
     catch (COMException exception)
     {
         throw ExceptionHelper.GetExceptionFromCOMException(context, exception);
     }
     catch (ActiveDirectoryObjectNotFoundException)
     {
         throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name }));
     }
     try
     {
         directoryEntry.RefreshCache(new string[] { "options" });
     }
     catch (COMException exception2)
     {
         if (exception2.ErrorCode != -2147016656)
         {
             throw ExceptionHelper.GetExceptionFromCOMException(context, exception2);
         }
         if (Utils.CheckCapability(DirectoryEntryManager.GetDirectoryEntry(context, WellKnownDN.RootDSE), Capability.ActiveDirectoryApplicationMode) && (transport == ActiveDirectoryTransportType.Smtp))
         {
             throw new NotSupportedException(Res.GetString("NotSupportTransportSMTP"));
         }
         throw new ActiveDirectoryObjectNotFoundException(Res.GetString("TransportNotFound", new object[] { transport.ToString() }), typeof(ActiveDirectoryInterSiteTransport), transport.ToString());
     }
     return new ActiveDirectoryInterSiteTransport(context, transport, directoryEntry);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:61,代码来源:ActiveDirectoryInterSiteTransport.cs

示例15: GetConfigurationSet

        public static ConfigurationSet GetConfigurationSet(DirectoryContext context)
        {
            // check that the argument is not null
            if (context == null)
                throw new ArgumentNullException("context");

            // target should ConfigurationSet or DirectoryServer
            if ((context.ContextType != DirectoryContextType.ConfigurationSet) &&
                (context.ContextType != DirectoryContextType.DirectoryServer))
            {
                throw new ArgumentException(Res.GetString(Res.TargetShouldBeServerORConfigSet), "context");
            }

            // target should be an adam config set or server
            if (((!context.isServer()) && (!context.isADAMConfigSet())))
            {
                // the target should be a server or an ADAM Config Set
                if (context.ContextType == DirectoryContextType.ConfigurationSet)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ConfigurationSet), context.Name);
                }
                else
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.AINotFound, context.Name), typeof(ConfigurationSet), null);
                }
            }

            //  work with copy of the context
            context = new DirectoryContext(context);

            //
            // bind to rootdse of an adam instance (if target is already a server, verify that it is an adam instance)
            //
            DirectoryEntryManager directoryEntryMgr = new DirectoryEntryManager(context);
            DirectoryEntry rootDSE = null;
            string configSetName = null;

            try
            {
                rootDSE = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
                if ((context.isServer()) && (!Utils.CheckCapability(rootDSE, Capability.ActiveDirectoryApplicationMode)))
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.AINotFound, context.Name), typeof(ConfigurationSet), null);
                }

                configSetName = (string)PropertyManager.GetPropertyValue(context, rootDSE, PropertyManager.ConfigurationNamingContext);
            }
            catch (COMException e)
            {
                int errorCode = e.ErrorCode;

                if (errorCode == unchecked((int)0x8007203a))
                {
                    if (context.ContextType == DirectoryContextType.ConfigurationSet)
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ConfigurationSet), context.Name);
                    }
                    else
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.AINotFound, context.Name), typeof(ConfigurationSet), null);
                    }
                }
                else
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                }
            }
            catch (ActiveDirectoryObjectNotFoundException)
            {
                if (context.ContextType == DirectoryContextType.ConfigurationSet)
                {
                    // this is the case when we could not find an ADAM instance in that config set
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.ConfigSetNotFound), typeof(ConfigurationSet), context.Name);
                }
                else
                    throw;
            }

            // return config set object
            return new ConfigurationSet(context, configSetName, directoryEntryMgr);
        }
开发者ID:chcosta,项目名称:corefx,代码行数:81,代码来源:ConfigSet.cs


注:本文中的System.DirectoryServices.ActiveDirectory.DirectoryContext.isServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。