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

  • SEARCH
  • Home
  • 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 6899923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:28:58+00:00 2026-05-27T07:28:58+00:00

how can I authenticate from PHP using LDAP when I only have the SamAccountName

  • 0

how can I authenticate from PHP using LDAP when I only have the SamAccountName and Password? Is there a way to bind with just SamAccountName and Password and without Distinguished Name. The only examples I have found assume you have the DN:

$server="XXX.XXX.XXX.XXX";
$dn = "cn=$username, "; 
$basedn="ou=users, ou=accounts, dc=domain, dc=com";

if (!($connect = ldap_connect($server))) { 
   die ("Could not connect to LDAP server"); 
} 

if (!($bind = ldap_bind($connect, "$dn" . "$basedn", $password))) {        
   die ("Could not bind to $dn"); 
} 

$sr = ldap_search($connect, $basedn,"$filter"); 
$info = ldap_get_entries($connect, $sr); 
$fullname=$info[0]["displayname"][0]; 
$fqdn=$info[0]["dn"]; 
  • 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-27T07:28:58+00:00Added an answer on May 27, 2026 at 7:28 am

    Actually, the answer is that it depends on how the LDAP server was configured by the admin. You don’t always need a DN to authenticate to an LDAP server. In my particular case, even with the DN, I still couldn’t authenticate to the LDAP server. For the LDAP server I was trying to connect, it appears it was a Microsoft Domain, and so I could only authenticate with DOMAIN\user015 for user015 in DOMAIN where user015 is a SamAccountName and DOMAIN is the domain for that user. But I was able to authenticate.

    Thank you for all the posts! Even if they weren’t the correct answer, they did help a lot!

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

Sidebar

Related Questions

I have a Java app that can authenticate to LDAP by logging users into
Using SQL Server 2005, how can I authenticate a username/password pair against a non-AD
i'm using spring+tapestry for authenticate webuser. I wonder is there any technique i can
I have the following code: $bind = new COM(LDAP://CN=GroupName,OU=Groups,OU=Division,DC=company,DC=local); When I execute it from
I have two webapplication, one is a simple authenticationsite which can authenticate the logged
I'm setting a CURL authentication, using CURLOPT_USERPWD: curl_setopt($curl_handle, CURLOPT_USERPWD, $login); // Authenticate How can
I have flash (AIR) application running on a single controlled system (there is only
I'm currently using NetBeans 6.9 with the PHP plugin and a PHP Application from
I have some tasks on a site in php using nginx that I'm trying
I have a web application that needs to be built using PHP/MySQL. The application

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.