/// <summary> /// </summary> /// <param name="directoryEntry"></param> public LDAPObject CreateObject(DirectoryEntry directoryEntry) { if (directoryEntry == null) throw new ArgumentNullException("directoryEntry"); LDAPObject result = null; string schemaClassName = null; try { schemaClassName = directoryEntry.SchemaClassName; } catch (Exception e) { _log.ErrorFormat("Can't get directoryEntry.SchemaClassName property. {0}", e); } finally { } switch (schemaClassName) { case Constants.ObjectClassKnowedValues.Domain: case Constants.ObjectClassKnowedValues.DomainDNS: result = new LDAPDomain(directoryEntry); break; case Constants.ObjectClassKnowedValues.User: result = new LDAPUser(directoryEntry); break; case Constants.ObjectClassKnowedValues.Computer: result = new LDAPComputer(directoryEntry); break; case Constants.ObjectClassKnowedValues.Group: result = new LDAPGroup(directoryEntry); break; case Constants.ObjectClassKnowedValues.Container: result = new LDAPContainer(directoryEntry); break; case Constants.ObjectClassKnowedValues.RpcContainer: result = new LDAPRpcContainer(directoryEntry); break; case Constants.ObjectClassKnowedValues.BuildInDomain: result = new LDAPBuildInDomain(directoryEntry); break; case Constants.ObjectClassKnowedValues.OrganizationalUnit: result = new LDAPOrganizationalUnit(directoryEntry); break; default: result = new LDAPOtherObject(directoryEntry); break; } return result; }
public static PropertyValueCollection GetGroupAttribute(LDAPGroup domainGroup, string groupAttribute) { try { return(domainGroup.GetValues(groupAttribute)); } catch (Exception e) { _log.ErrorFormat("Wrong Group Attribute parameters: {0}. {1}", groupAttribute, e); } return(null); }
private static bool CheckGroupAttribute(LDAPGroup group, string groupAttr) { try { var groupAttribute = group.GetValues(groupAttr); if (groupAttribute == null) { _log.ErrorFormat("Wrong Group Attribute parameter: {0}", groupAttr); return(false); } } catch (Exception e) { _log.ErrorFormat("Wrong Group Attribute parameter: {0}. {1}", groupAttr, e); return(false); } return(true); }
public static bool UserExistsInGroup(LDAPGroup domainGroup, string memberString, string groupAttribute) { try { var members = domainGroup.GetValues(groupAttribute); if (memberString != null) { foreach (var member in members) { if (memberString.ToString().Equals(member.ToString(), StringComparison.InvariantCultureIgnoreCase)) { return(true); } } } } catch (Exception e) { _log.ErrorFormat("Wrong Group Attribute parameters: {0}. {1}", groupAttribute, e); } return(false); }
/// <summary> /// </summary> /// <param name="directoryEntry"></param> public LDAPObject CreateObject(DirectoryEntry directoryEntry) { if (directoryEntry == null) { throw new ArgumentNullException("directoryEntry"); } LDAPObject result = null; string schemaClassName = null; try { schemaClassName = directoryEntry.SchemaClassName; } catch (Exception e) { _log.ErrorFormat("Can't get directoryEntry.SchemaClassName property. {0}", e); } finally { } switch (schemaClassName) { case Constants.ObjectClassKnowedValues.Domain: case Constants.ObjectClassKnowedValues.DomainDNS: result = new LDAPDomain(directoryEntry); break; case Constants.ObjectClassKnowedValues.User: result = new LDAPUser(directoryEntry); break; case Constants.ObjectClassKnowedValues.Computer: result = new LDAPComputer(directoryEntry); break; case Constants.ObjectClassKnowedValues.Group: result = new LDAPGroup(directoryEntry); break; case Constants.ObjectClassKnowedValues.Container: result = new LDAPContainer(directoryEntry); break; case Constants.ObjectClassKnowedValues.RpcContainer: result = new LDAPRpcContainer(directoryEntry); break; case Constants.ObjectClassKnowedValues.BuildInDomain: result = new LDAPBuildInDomain(directoryEntry); break; case Constants.ObjectClassKnowedValues.OrganizationalUnit: result = new LDAPOrganizationalUnit(directoryEntry); break; default: result = new LDAPOtherObject(directoryEntry); break; } return(result); }
public static PropertyValueCollection GetGroupAttribute(LDAPGroup domainGroup, string groupAttribute) { try { return domainGroup.GetValues(groupAttribute); } catch (Exception e) { _log.ErrorFormat("Wrong Group Attribute parameters: {0}. {1}", groupAttribute, e); } return null; }
public static bool UserExistsInGroup(LDAPGroup domainGroup, string memberString, string groupAttribute) { try { var members = domainGroup.GetValues(groupAttribute); if (memberString != null) { foreach (var member in members) { if (memberString.ToString().Equals(member.ToString(), StringComparison.InvariantCultureIgnoreCase)) { return true; } } } } catch (Exception e) { _log.ErrorFormat("Wrong Group Attribute parameters: {0}. {1}", groupAttribute, e); } return false; }
private static bool CheckGroupAttribute(LDAPGroup group, string groupAttr) { try { var groupAttribute = group.GetValues(groupAttr); if (groupAttribute == null) { _log.ErrorFormat("Wrong Group Attribute parameter: {0}", groupAttr); return false; } } catch (Exception e) { _log.ErrorFormat("Wrong Group Attribute parameter: {0}. {1}", groupAttr, e); return false; } return true; }