/// <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;
        }
예제 #2
0
 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);
 }
예제 #3
0
 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);
 }
예제 #4
0
 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);
 }
예제 #5
0
        /// <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);
        }
예제 #6
0
 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;
 }
예제 #7
0
 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;
 }
예제 #8
0
 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;
 }