Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 677485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:02:40+00:00 2026-05-14T01:02:40+00:00

I am using adldap http://adldap.sourceforge.net/ And I am passing the session from page to

  • 0

I am using adldap http://adldap.sourceforge.net/

And I am passing the session from page to page, and checking to make sure the username within the session is a member of a certain member group, for this example, it is the STAFF group.

<?php
    ini_set('display_errors',1);
    error_reporting(E_ALL);
    require_once('/web/ee_web/include/adLDAP.php');
    $adldap = new adLDAP();

    session_start();

    $group = "STAFF";

    //$authUser = $adldap->authenticate($username, $password);

    $result=$adldap->user_groups($_SESSION['user_session']);

    foreach($result as $key=>$value) {
        switch($value) {
            case $group:
                print '<h3>'.$group.'</h3>';
                break;

            default:
                print '<h3>Did not find specific value: '.$value.'</h3>';
            }
        if($value == $group) { print 'for loop broke'; break; }
    }
?>

It gives me the error: Warning: Invalid argument supplied for foreach() on line 15, which is this line of code: foreach($result as $key=>$value) {

When I uncomment the code $authUser = $adldap->authenticate($username, $password); and enter in the appropriate username and password, it works fine, but I shouldn’t have to, since the session is valid, I just want to see if the username stored within the valid_session is apart of the STAFF group.

Why would it be giving me that problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:02:41+00:00Added an answer on May 14, 2026 at 1:02 am

    According to this source file, user_groups() will, return false if the user name was empty (and in some other cases too, check the source). I bet your $_SESSION["user_session"] is empty, and $result is then false. You can’t run foreach on a non-array which is why you get the warning.

    You will need to find out why your session variable is empty, and/or check whether $result is an array because doing a foreach on it:

    if (is_array($result))
     foreach ($result....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.