views:

41

answers:

1

http://adldap.sourceforge.net/wiki/doku.php?id=api_user_functions#user_ingroup_username_group_recursive_null

I am using the adLDAP class above to authenticate users against our ldap server.

I was wondering how I could check multiple groups to see if the user belongs to either, if they belong to either.

I don't know if

user_ingroup($username,$group,$recursive=NULL);

can handle search two different groups for the user, need help coding it to search for the user in two different groups, and as soon as it finds it in one of those, break the operation and set a variable to true.

Any help is appreciated.

A: 
<?php
$groups = array("FACULTY","STAFF");

if(isset($_SESSION['user_session'])) {
    $username = $_SESSION['user_session'];
    foreach ($groups as $i => $group) {
      $user_in_group = $adldap->user_ingroup($username,$group);
      print '<h1>group '.$user_in_group.'</h1>';
      if($user_in_group) {
        break;
      }
    }
}?>

Figured it out, unless there is a better way, let me know. Thank you.

Brad