本文整理汇总了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");
}
}
示例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);
}
示例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);
}