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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:29:28+00:00 2026-06-01T08:29:28+00:00

I am looking for a basic ldap script that is checking if an Active

  • 0

I am looking for a basic ldap script that is checking if an Active Directory for a user/password combination.

I mention that, the authentication to LDAP is done using another account than the ones being verified.

Here is my incomplete script:

#!/usr/bin/env python
import ldap
import sys

Server = "ldap://pdc01.example.com"
DN = "EXAMPLE\username"
Secret = "pass"
un = "john"
un_password = "hispass"
Base = "dc=example,dc=com"

Scope = ldap.SCOPE_SUBTREE
Filter = "(&(objectClass=user)(sAMAccountName="+un+"))"
Attrs = ["displayName"]

l = ldap.initialize(Server)
l.set_option(ldap.OPT_REFERRALS, 0)
l.protocol_version = 3
print l.simple_bind_s(DN, Secret)

r = l.search(Base, Scope, Filter, Attrs)
Type,user = l.result(r,60)
Name,Attrs = user[0]
if hasattr(Attrs, 'has_key') and Attrs.has_key('displayName'):
  displayName = Attrs['displayName'][0]
  print displayName

# TODO: I get `john`'s Username but how to check his password ?

l.unbind()
  • 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-01T08:29:29+00:00Added an answer on June 1, 2026 at 8:29 am

    If the distinguished name of the entry being checked and its credentials are already known, transmit a simple bind request including the credentials, if successful, the password is correct ad the account is usable (as opposed to being locked or disabled). Alternatively, a SASL mechanism could be used with a bind request.

    If the distinguished name is not known, transmit a search request to the directory server using a connection with sufficient authorization to read the distinguished name of the entry. The search request must contain the base object to which the entry is expected to be subordinate, should use the tightest possible scope (if the distinguished name is not known, this will be one, or sub), should use the most restrictive filter as is possible given known information, and request the attribute 1.1 since all that is required is the distinguished name of the entry. The search response will contain the distinguished name of the entry, assuming the search was successful. Once the distinguished name is known, transmit a bind request as noted above.

    see also

    • LDAP: Mastering Search Filters
    • LDAP: Search best practices
    • LDAP: Programming practices
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for a Javascript library that supports loading of a basic an animation file/script(could
I'm looking for some tool that would do basic testing of PHP script. This
I am looking for a basic script/command that will create a copy of a
I'm looking at doing a very basic authentication script as follows: <?php // admin.php
I am looking into a basic DOM layout that lets me put a couple
I'm looking for any beyond basic resources that can help me to be proficient
I'm looking to do basic eye tracking using an Android tablet, hopefully to track
I am looking for a basic Django application that looks good and has basic
I'm looking to do basic stuff with sessions (user logins, authenticated forms & pages)
i am looking for a basic example that shows how i could call a

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.