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 8400737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:38:01+00:00 2026-06-09T21:38:01+00:00

I’m trying to accomplish something very similar to what this user was doing Here

  • 0

I’m trying to accomplish something very similar to what this user was doing Here.

I followed the answer, but I could not get it working. Inside the Active directory, my memberOf field looks like this:

CN=$VPN Users,CN=Users,DC=iai,DC=pri,CN=$ITAR,CN=Users,DC=iai,DC=pri,CN=allsubscribers,CN=Users,DC=iai,DC=pri

My Filter that works is:

(&(objectCategory=person)(sAMAccountName=$p_username))

I’m trying to get the following to work:

(&(objectCategory=person)(sAMAccountName=$p_username)(memberOf=CN=$ITAR))

I have tried adding the full DN which is
CN=Users,DC=iai,DC=pri
to my filter as well, but I get:

array(1) { ["count"]=> int(0) } 

as my response.

I’m using ldap 3

This is the partial Working authentication code written in php:

  $login = ldap_bind( $url, "username@somedomain", $password ); 

  $attributes = array("displayname", "mailnickname");
  $filter = "(&(objectCategory=person)(sAMAccountName=$username))";

  $result = ldap_search($url, "CN=Users,DC=iai,DC=pri", $filter, $attributes);

  $entries = ldap_get_entries($url, $result);

What am I doing wrong?

Code Result

From @DaveRandom

First Var dump:

string(49) "(&(objectCategory=person)(sAMAccountName=rmoser))"
array(2) {
  ["count"] => int(1)
  [0] => array(8) {
    ["displayname"] => array(2) {
      ["count"] => int(1)
      [0] => string(10) "Ryan Moser"
    }
    [0] => string(11) "displayname"
    ["memberof"] => array(4) {
      ["count"] => int(3)
      [0] => string(36) "CN=$VPN Users,CN=Users,DC=iai,DC=pri"
      [1] => string(31) "CN=$ITAR,CN=Users,DC=iai,DC=pri"
      [2] => string(40) "CN=allsubscribers,CN=Users,DC=iai,DC=pri"
    }
    [1]=> string(8) "memberof"
    ["mailnickname"] => array(2) {
      ["count"] => int(1)
      [0] => string(6) "rmoser"
    }
    [2] => string(12) "mailnickname"
    ["count"] => int(3)
    ["dn"] => string(36) "CN=Ryan Moser,CN=Users,DC=iai,DC=pri"
  }
}
bool(false)

Second var_dump:

string(70) "(&(objectCategory=person)(sAMAccountName=rmoser)(memberof=*CN=$ITAR*))" 
array(1) {
  ["count"] => int(0)
} 
  • 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-06-09T21:38:02+00:00Added an answer on June 9, 2026 at 9:38 pm

    LDAP filters look for an exact match.

    In order to match CN=$ITAR anywhere in a value, you will need to surround it with the filter wildcard character *.

    Try this filter:

    (&(objectCategory=person)(sAMAccountName=$p_username)(memberOf=*CN=$ITAR*))
    

    Also don’t forget that $ITAR is a valid variable name in PHP, so if you place that filter string in double quotes (which you would need to in order for $p_username to be interpolated) PHP will attempt to interpolate $ITAR as a variable as well, find that it (probably) doesn’t exist and the end result will be that it gets stripped from the string.

    $filter = "(&(objectCategory=person)(sAMAccountName=$p_username)(memberOf=*CN=\$ITAR*))";
    

    A useful link for any question concerning a dynamic filter built with PHP is this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.

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.