本文整理汇总了C#中System.DirectoryServices.ActiveDirectory.DirectoryContext.GetServerName方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryContext.GetServerName方法的具体用法?C# DirectoryContext.GetServerName怎么用?C# DirectoryContext.GetServerName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DirectoryServices.ActiveDirectory.DirectoryContext
的用法示例。
在下文中一共展示了DirectoryContext.GetServerName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ActiveDirectorySchemaClass
// Internal constructor
internal ActiveDirectorySchemaClass(DirectoryContext context, string ldapDisplayName, DirectoryEntry classEntry, DirectoryEntry schemaEntry)
{
_context = context;
_ldapDisplayName = ldapDisplayName;
_classEntry = classEntry;
_schemaEntry = schemaEntry;
// this constructor is only called for non-defunct classes
_isDefunctOnServer = false;
_isDefunct = _isDefunctOnServer;
// initialize the directory entry for the abstract schema class
try
{
_abstractClassEntry = DirectoryEntryManager.GetDirectoryEntryInternal(context, "LDAP://" + context.GetServerName() + "/schema/" + ldapDisplayName);
_iadsClass = (NativeComInterfaces.IAdsClass)_abstractClassEntry.NativeObject;
}
catch (COMException e)
{
if (e.ErrorCode == unchecked((int)0x80005000))
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DSNotFound), typeof(ActiveDirectorySchemaClass), ldapDisplayName);
}
else
{
throw ExceptionHelper.GetExceptionFromCOMException(context, e);
}
}
catch (InvalidCastException)
{
// this means that we found an object but it is not a schema class
throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DSNotFound), typeof(ActiveDirectorySchemaClass), ldapDisplayName);
}
catch (ActiveDirectoryObjectNotFoundException)
{
// this is the case where the context is a config set and we could not find an ADAM instance in that config set
throw new ActiveDirectoryOperationException(Res.GetString(Res.ADAMInstanceNotFoundInConfigSet, context.Name));
}
// set the bind flag
this.isBound = true;
}
示例2: ActiveDirectorySchemaClass
internal ActiveDirectorySchemaClass(DirectoryContext context, string ldapDisplayName, DirectoryEntry classEntry, DirectoryEntry schemaEntry)
{
this.type = SchemaClassType.Structural;
this.context = context;
this.ldapDisplayName = ldapDisplayName;
this.classEntry = classEntry;
this.schemaEntry = schemaEntry;
this.isDefunctOnServer = false;
this.isDefunct = this.isDefunctOnServer;
try
{
this.abstractClassEntry = DirectoryEntryManager.GetDirectoryEntryInternal(context, "LDAP://" + context.GetServerName() + "/schema/" + ldapDisplayName);
this.iadsClass = (NativeComInterfaces.IAdsClass) this.abstractClassEntry.NativeObject;
}
catch (COMException exception)
{
if (exception.ErrorCode == -2147463168)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySchemaClass), ldapDisplayName);
}
throw ExceptionHelper.GetExceptionFromCOMException(context, exception);
}
catch (InvalidCastException)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySchemaClass), ldapDisplayName);
}
catch (ActiveDirectoryObjectNotFoundException)
{
throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name }));
}
this.isBound = true;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:32,代码来源:ActiveDirectorySchemaClass.cs
示例3: ActiveDirectorySchemaProperty
internal ActiveDirectorySchemaProperty(DirectoryContext context, string ldapDisplayName, DirectoryEntry propertyEntry, DirectoryEntry schemaEntry)
{
this.syntax = ~ActiveDirectorySyntax.CaseExactString;
this.rangeLower = null;
this.rangeUpper = null;
this.linkId = null;
this.context = context;
this.ldapDisplayName = ldapDisplayName;
this.propertyEntry = propertyEntry;
this.isDefunctOnServer = false;
this.isDefunct = this.isDefunctOnServer;
try
{
this.abstractPropertyEntry = DirectoryEntryManager.GetDirectoryEntryInternal(context, "LDAP://" + context.GetServerName() + "/schema/" + ldapDisplayName);
this.iadsProperty = (NativeComInterfaces.IAdsProperty) this.abstractPropertyEntry.NativeObject;
}
catch (COMException exception)
{
if (exception.ErrorCode == -2147463168)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySchemaProperty), ldapDisplayName);
}
throw ExceptionHelper.GetExceptionFromCOMException(context, exception);
}
catch (InvalidCastException)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySchemaProperty), ldapDisplayName);
}
catch (ActiveDirectoryObjectNotFoundException)
{
throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", new object[] { context.Name }));
}
this.isBound = true;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:ActiveDirectorySchemaProperty.cs
示例4: ActiveDirectorySchemaProperty
internal ActiveDirectorySchemaProperty(DirectoryContext context, string ldapDisplayName, DirectoryEntry propertyEntry, DirectoryEntry schemaEntry)
{
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;
this.context = context;
this.ldapDisplayName = ldapDisplayName;
this.propertyEntry = propertyEntry;
this.isDefunctOnServer = false;
this.isDefunct = this.isDefunctOnServer;
try
{
this.abstractPropertyEntry = DirectoryEntryManager.GetDirectoryEntryInternal(context, string.Concat("LDAP://", context.GetServerName(), "/schema/", ldapDisplayName));
this.iadsProperty = (NativeComInterfaces.IAdsProperty)this.abstractPropertyEntry.NativeObject;
}
catch (COMException cOMException1)
{
COMException cOMException = cOMException1;
if (cOMException.ErrorCode != -2147463168)
{
throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException);
}
else
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySchemaProperty), ldapDisplayName);
}
}
catch (InvalidCastException invalidCastException)
{
throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DSNotFound"), typeof(ActiveDirectorySchemaProperty), ldapDisplayName);
}
catch (ActiveDirectoryObjectNotFoundException activeDirectoryObjectNotFoundException)
{
object[] name = new object[1];
name[0] = context.Name;
throw new ActiveDirectoryOperationException(Res.GetString("ADAMInstanceNotFoundInConfigSet", name));
}
this.isBound = true;
}
示例5: GetDirectoryEntry
internal static DirectoryEntry GetDirectoryEntry(DirectoryContext context, string dn)
{
string tempBindingPrefix = "LDAP://" + context.GetServerName() + "/";
NativeComInterfaces.IAdsPathname pathCracker = (NativeComInterfaces.IAdsPathname)new NativeComInterfaces.Pathname();
pathCracker.EscapedMode = NativeComInterfaces.ADS_ESCAPEDMODE_ON;
pathCracker.Set(dn, NativeComInterfaces.ADS_SETTYPE_DN);
string escapedDN = pathCracker.Retrieve(NativeComInterfaces.ADS_FORMAT_X500_DN);
return Bind(tempBindingPrefix + escapedDN, context.UserName, context.Password, context.useServerBind());
}
示例6: GetDirectoryEntry
internal static DirectoryEntry GetDirectoryEntry(DirectoryContext context, string dn)
{
string str = string.Concat("LDAP://", context.GetServerName(), "/");
/* NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname)(new NativeComInterfaces.Pathname());
pathname.EscapedMode = 2;
pathname.Set(dn, 4);
string str1 = pathname.Retrieve(7);
*/
string str1 = dn;
return DirectoryEntryManager.Bind(string.Concat(str, str1), context.UserName, context.Password, context.useServerBind());
}
示例7: GetDirectoryEntry
internal static DirectoryEntry GetDirectoryEntry(DirectoryContext context, string dn)
{
string str = "LDAP://" + context.GetServerName() + "/";
NativeComInterfaces.IAdsPathname pathname = (NativeComInterfaces.IAdsPathname) new NativeComInterfaces.Pathname();
pathname.EscapedMode = 2;
pathname.Set(dn, 4);
string str2 = pathname.Retrieve(7);
return Bind(str + str2, context.UserName, context.Password, context.useServerBind());
}
示例8: GetExceptionFromCOMException
internal static Exception GetExceptionFromCOMException(DirectoryContext context, COMException e)
{
Exception exception;
int errorCode = e.ErrorCode;
string errorMessage = e.Message;
//
// Check if we can throw a more specific exception
//
if (errorCode == unchecked((int)0x80070005))
{
//
// Access Denied
//
exception = new UnauthorizedAccessException(errorMessage, e);
}
else if (errorCode == unchecked((int)0x8007052e))
{
//
// Logon Failure
//
exception = new AuthenticationException(errorMessage, e);
}
else if (errorCode == unchecked((int)0x8007202f))
{
//
// Constraint Violation
//
exception = new InvalidOperationException(errorMessage, e);
}
else if (errorCode == unchecked((int)0x80072035))
{
//
// Unwilling to perform
//
exception = new InvalidOperationException(errorMessage, e);
}
else if (errorCode == unchecked((int)0x80071392))
{
//
// Object already exists
//
exception = new ActiveDirectoryObjectExistsException(errorMessage, e);
}
else if (errorCode == unchecked((int)0x80070008))
{
//
// No Memory
//
exception = new OutOfMemoryException();
}
else if ((errorCode == unchecked((int)0x8007203a)) || (errorCode == unchecked((int)0x8007200e)) || (errorCode == unchecked((int)0x8007200f)))
{
//
// ServerDown/Unavailable/Busy
//
if (context != null)
{
exception = new ActiveDirectoryServerDownException(errorMessage, e, errorCode, context.GetServerName());
}
else
{
exception = new ActiveDirectoryServerDownException(errorMessage, e, errorCode, null);
}
}
else
{
//
// Wrap the exception in a generic OperationException
//
exception = new ActiveDirectoryOperationException(errorMessage, e, errorCode);
}
return exception;
}
示例9: GetExceptionFromCOMException
internal static Exception GetExceptionFromCOMException(DirectoryContext context, COMException e)
{
int errorCode = e.ErrorCode;
string message = e.Message;
switch (errorCode)
{
case -2147024891:
return new UnauthorizedAccessException(message, e);
case -2147023570:
return new AuthenticationException(message, e);
case -2147016657:
return new InvalidOperationException(message, e);
case -2147016651:
return new InvalidOperationException(message, e);
case -2147019886:
return new ActiveDirectoryObjectExistsException(message, e);
case -2147024888:
return new OutOfMemoryException();
case -2147016646:
case -2147016690:
case -2147016689:
if (context != null)
{
return new ActiveDirectoryServerDownException(message, e, errorCode, context.GetServerName());
}
return new ActiveDirectoryServerDownException(message, e, errorCode, null);
}
return new ActiveDirectoryOperationException(message, e, errorCode);
}
示例10: GetExceptionFromCOMException
internal static Exception GetExceptionFromCOMException(DirectoryContext context, COMException e)
{
Exception activeDirectoryServerDownException;
int errorCode = e.ErrorCode;
string message = e.Message;
if (errorCode != -2147024891)
{
if (errorCode != -2147023570)
{
if (errorCode != -2147016657)
{
if (errorCode != -2147016651)
{
if (errorCode != -2147019886)
{
if (errorCode != -2147024888)
{
if (errorCode == -2147016646 || errorCode == -2147016690 || errorCode == -2147016689)
{
if (context == null)
{
activeDirectoryServerDownException = new ActiveDirectoryServerDownException(message, e, errorCode, null);
}
else
{
activeDirectoryServerDownException = new ActiveDirectoryServerDownException(message, e, errorCode, context.GetServerName());
}
}
else
{
activeDirectoryServerDownException = new ActiveDirectoryOperationException(message, e, errorCode);
}
}
else
{
activeDirectoryServerDownException = new OutOfMemoryException();
}
}
else
{
activeDirectoryServerDownException = new ActiveDirectoryObjectExistsException(message, e);
}
}
else
{
activeDirectoryServerDownException = new InvalidOperationException(message, e);
}
}
else
{
activeDirectoryServerDownException = new InvalidOperationException(message, e);
}
}
else
{
activeDirectoryServerDownException = new AuthenticationException(message, e);
}
}
else
{
activeDirectoryServerDownException = new UnauthorizedAccessException(message, e);
}
return activeDirectoryServerDownException;
}