Beispiel #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 public object Clone()
 {
     Criteria cr = new Criteria(_type);
     foreach (var ex in _expressions)
     {
         cr._expressions.Add(ex.Clone() as Expression);
     }
     foreach (var nc in _nestedCriteras)
     {
         cr._nestedCriteras.Add(nc.Clone() as Criteria);
     }
     return cr;
 }
Beispiel #2
0
 /// <summary>
 
 /// </summary>
 /// <param name="nested"></param>
 
 public Criteria Add(Criteria nested)
 {
     _nestedCriteras.Add(nested);
     return this;
 }
Beispiel #3
0
        public static List<LDAPObject> Search(string root, Criteria criteria, string userFilter, LDAPSupportSettings settings)
        {
            var type = AuthenticationTypes.ReadonlyServer | AuthenticationTypes.Secure;
            string password;
            try
            {
                password = new UnicodeEncoding().GetString(InstanceCrypto.Decrypt(settings.PasswordBytes));
            }
            catch (Exception)
            {
                password = string.Empty;
            }
            if (settings.PortNumber == Constants.SSL_LDAP_PORT)
            {
                type |= AuthenticationTypes.SecureSocketsLayer;
            }
            var entry = settings.Authentication ? new DirectoryEntry(root, settings.Login, password, type) : new DirectoryEntry(root);
            try
            {
                object nativeObject = entry.NativeObject;
            }
            catch (Exception e)
            {
                _log.ErrorFormat("Error authenticating user. Current user has not access to read this directory: {0}. {1}", root, e);
                return new List<LDAPObject>(0);
            }

            if (!string.IsNullOrEmpty(userFilter) && !userFilter.StartsWith("(") && !userFilter.EndsWith(")"))
            {
                userFilter = "(" + userFilter + ")";
            }

            return SearchInternal(root, criteria != null ? "(&" + criteria.ToString() + userFilter + ")" : userFilter, SearchScope.Subtree, settings);
        }