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


C# DirectoryContext.isNdnc方法代码示例

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


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

示例1: GetApplicationPartition

		public static ApplicationPartition GetApplicationPartition(DirectoryContext context)
		{
			if (context != null)
			{
				if (context.ContextType == DirectoryContextType.ApplicationPartition)
				{
					if (context.isNdnc())
					{
						context = new DirectoryContext(context);
						string dNFromDnsName = Utils.GetDNFromDnsName(context.Name);
						DirectoryEntryManager directoryEntryManager = new DirectoryEntryManager(context);
						try
						{
							DirectoryEntry cachedDirectoryEntry = directoryEntryManager.GetCachedDirectoryEntry(dNFromDnsName);
							//TODO: REVIEW: URGENT: cachedDirectoryEntry.Bind(true);
						}
						catch (COMException cOMException1)
						{
							COMException cOMException = cOMException1;
							int errorCode = cOMException.ErrorCode;
							if (errorCode != -2147016646)
							{
								throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException);
							}
							else
							{
								throw new ActiveDirectoryObjectNotFoundException(Res.GetString("NDNCNotFound"), typeof(ApplicationPartition), context.Name);
							}
						}
						return new ApplicationPartition(context, dNFromDnsName, context.Name, ApplicationPartitionType.ADApplicationPartition, directoryEntryManager);
					}
					else
					{
						throw new ActiveDirectoryObjectNotFoundException(Res.GetString("NDNCNotFound"), typeof(ApplicationPartition), context.Name);
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("TargetShouldBeAppNCDnsName"), "context");
				}
			}
			else
			{
				throw new ArgumentNullException("context");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:46,代码来源:ApplicationPartition.cs

示例2: GetApplicationPartition

        public static ApplicationPartition GetApplicationPartition(DirectoryContext context)
        {
            // validate the context
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            // contexttype should be ApplicationPartiton
            if (context.ContextType != DirectoryContextType.ApplicationPartition)
            {
                throw new ArgumentException(Res.GetString(Res.TargetShouldBeAppNCDnsName), "context");
            }

            // target must be ndnc dns name
            if (!context.isNdnc())
            {
                throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.NDNCNotFound), typeof(ApplicationPartition), context.Name);
            }

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

            // bind to the application partition head (this will verify credentials)
            string distinguishedName = Utils.GetDNFromDnsName(context.Name);
            DirectoryEntryManager directoryEntryMgr = new DirectoryEntryManager(context);
            DirectoryEntry appNCHead = null;

            try
            {
                appNCHead = directoryEntryMgr.GetCachedDirectoryEntry(distinguishedName);
                // need to force the bind
                appNCHead.Bind(true);
            }
            catch (COMException e)
            {
                int errorCode = e.ErrorCode;

                if (errorCode == unchecked((int)0x8007203a))
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.NDNCNotFound), typeof(ApplicationPartition), context.Name);
                }
                else
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                }
            }

            return new ApplicationPartition(context, distinguishedName, context.Name, ApplicationPartitionType.ADApplicationPartition, directoryEntryMgr);
        }
开发者ID:chcosta,项目名称:corefx,代码行数:50,代码来源:ApplicationPartition.cs

示例3: GetApplicationPartition

 public static ApplicationPartition GetApplicationPartition(DirectoryContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (context.ContextType != DirectoryContextType.ApplicationPartition)
     {
         throw new ArgumentException(Res.GetString("TargetShouldBeAppNCDnsName"), "context");
     }
     if (!context.isNdnc())
     {
         throw new ActiveDirectoryObjectNotFoundException(Res.GetString("NDNCNotFound"), typeof(ApplicationPartition), context.Name);
     }
     context = new DirectoryContext(context);
     string dNFromDnsName = Utils.GetDNFromDnsName(context.Name);
     DirectoryEntryManager directoryEntryMgr = new DirectoryEntryManager(context);
     try
     {
         directoryEntryMgr.GetCachedDirectoryEntry(dNFromDnsName).Bind(true);
     }
     catch (COMException exception)
     {
         if (exception.ErrorCode == -2147016646)
         {
             throw new ActiveDirectoryObjectNotFoundException(Res.GetString("NDNCNotFound"), typeof(ApplicationPartition), context.Name);
         }
         throw ExceptionHelper.GetExceptionFromCOMException(context, exception);
     }
     return new ApplicationPartition(context, dNFromDnsName, context.Name, ApplicationPartitionType.ADApplicationPartition, directoryEntryMgr);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:31,代码来源:ApplicationPartition.cs


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