public bool UserExistsInGroup(LDAPObject domainGroup, string memberString, string groupAttribute)
        {
            try
            {
                if (domainGroup == null ||
                    string.IsNullOrEmpty(memberString) ||
                    string.IsNullOrEmpty(groupAttribute))
                {
                    return(false);
                }

                var members = domainGroup.GetValues(groupAttribute);
                if (members == null)
                {
                    return(false);
                }

                if (members.Any(member => memberString.Equals(member, StringComparison.InvariantCultureIgnoreCase)))
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Wrong Group Attribute parameters: {0}. {1}", groupAttribute, e);
            }
            return(false);
        }
Beispiel #2
0
 public List <string> GetGroupAttribute(LDAPObject domainGroup, string groupAttribute)
 {
     try
     {
         return(domainGroup.GetValues(groupAttribute));
     }
     catch (Exception e)
     {
         Log.ErrorFormat("Wrong Group Attribute parameters: {0}. {1}", groupAttribute, e);
     }
     return(null);
 }
Beispiel #3
0
        public bool UserExistsInGroup(LDAPSupportSettings settings, LDAPObject domainGroup, string memberString, string groupAttribute)
        {
            try
            {
                if (domainGroup == null ||
                    string.IsNullOrEmpty(memberString) ||
                    string.IsNullOrEmpty(groupAttribute))
                {
                    return(false);
                }

                if (domainGroup.Sid.EndsWith("-513"))
                {
                    // Domain Users found

                    var ldapUsers = GetUsersFromPrimaryGroup(settings, "513");

                    if (ldapUsers == null)
                    {
                        return(false);
                    }

                    if (ldapUsers.Any(ldapUser => ldapUser.DistinguishedName.Equals(memberString, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        return(true);
                    }
                }
                else
                {
                    var members = domainGroup.GetValues(groupAttribute);

                    if (members == null)
                    {
                        return(false);
                    }

                    if (members.Any(member => memberString.Equals(member, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        return(true);
                    }
                }
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Wrong Group Attribute parameters: {0}. {1}", groupAttribute, e);
            }
            return(false);
        }
Beispiel #4
0
 protected bool CheckGroupNameAttribute(LDAPObject group, string groupAttr)
 {
     try
     {
         var groupNameAttribute = group.GetValues(groupAttr);
         if (groupNameAttribute == null)
         {
             log.ErrorFormat("Wrong Group Name Attribute parameter: {0}", groupAttr);
             return(false);
         }
     }
     catch (Exception e)
     {
         log.ErrorFormat("Wrong Group Attribute parameter: {0}. {1}", groupAttr, e);
         return(false);
     }
     return(true);
 }
Beispiel #5
0
 public bool UserExistsInGroup(LDAPObject domainGroup, string memberString, string groupAttribute)
 {
     try
     {
         var members = domainGroup.GetValues(groupAttribute);
         if (memberString != null)
         {
             foreach (var member in members)
             {
                 if (memberString.Equals(member, StringComparison.InvariantCultureIgnoreCase))
                 {
                     return(true);
                 }
             }
         }
     }
     catch (Exception e)
     {
         log.ErrorFormat("Wrong Group Attribute parameters: {0}. {1}", groupAttribute, e);
     }
     return(false);
 }