--- a/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/ldap.php Tue Jan 08 23:21:25 2013 -0500
+++ b/packages/ssoinabox-webui/root/usr/local/share/ssoinabox/htdocs/includes/ldap.php Fri Jan 11 00:32:54 2013 -0500
@@ -353,3 +353,20 @@
return ldap_delete($_ldapconn, ldap_make_group_dn($cn));
}
+
+/**
+ * Is the given username in the specified LDAP group?
+ * @param string username
+ * @param string Group name
+ * @return bool
+ */
+
+function ldap_test_group_membership($username, $group)
+{
+ global $_ldapconn, $ldap_group_basedn;
+
+ $filter = sprintf('(&(memberUid=%s)(cn=%s)(objectClass=posixGroup))', ldap_escape($username), ldap_escape($group));
+
+ $result = ldap_search($_ldapconn, $ldap_group_basedn, $filter);
+ return ldap_count_entries($_ldapconn, $result) > 0;
+}