diff --git a/Frends.LDAP.AddUserToGroups/Frends.LDAP.AddUserToGroups.Tests/UnitTests.cs b/Frends.LDAP.AddUserToGroups/Frends.LDAP.AddUserToGroups.Tests/UnitTests.cs index 792dc03..ec7207c 100644 --- a/Frends.LDAP.AddUserToGroups/Frends.LDAP.AddUserToGroups.Tests/UnitTests.cs +++ b/Frends.LDAP.AddUserToGroups/Frends.LDAP.AddUserToGroups.Tests/UnitTests.cs @@ -148,11 +148,8 @@ private void DeleteTestUsers(string userDn, string groupDn) LdapAttribute memberAttr = groupEntry.GetAttribute("member"); var currentMembers = memberAttr.StringValueArray; - foreach (var member in currentMembers) - { - if (member == userDn) - remove = true; - } + if (currentMembers.Where(e => e == userDn).Any()) + remove = true; if (remove) { diff --git a/Frends.LDAP.AddUserToGroups/Frends.LDAP.AddUserToGroups/AddUserToGroups.cs b/Frends.LDAP.AddUserToGroups/Frends.LDAP.AddUserToGroups/AddUserToGroups.cs index f68ddac..af42667 100644 --- a/Frends.LDAP.AddUserToGroups/Frends.LDAP.AddUserToGroups/AddUserToGroups.cs +++ b/Frends.LDAP.AddUserToGroups/Frends.LDAP.AddUserToGroups/AddUserToGroups.cs @@ -91,7 +91,7 @@ private static bool UserExistsInGroup(LdapConnection connection, string userDn, { LdapAttribute memberAttr = entry.GetAttribute("member"); var currentMembers = memberAttr.StringValueArray; - foreach (var member in currentMembers.Where(e => e == userDn)) + if (currentMembers.Where(e => e == userDn).Any()) return true; } }