Sign in to follow this  
Followers 0
Lew

Authenticate with Active Directory

10 posts in this topic

I want to build some scripts that will authenticate with active directory. Does any one have any good functions or UDFs for me to look at? Thanks in advance.

Share this post


Link to post
Share on other sites



search the forum first ;)

Share this post


Link to post
Share on other sites

search the forum first ;)

I've been looking around the forums but can't fine what I am looking for yet but just want to see if anybody had something I could look at that they might have came across. :):)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What do you want to do exactly?

If you just want to check a given userid/password against the AD then you will find some solutions on the forum.

Or you could use this tool.

If you run Windows 7 you could use the latest version of my AD UDF (for download please see my signature). Just call _AD_Open() with userid/password and check the return code.

This function is not yet available in version 0.39. If you want to test it I will send you the latest version.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

What I would like to do is have it authenticate with user and password to the AD and also have it check to see if they are a member of a group.

Share this post


Link to post
Share on other sites

For the current user this would look like:

#include <AD.au3>
If _AD_Open() <> 1 Then
  MsgBox(0,"AD","Error " & @error " returned by _AD_Open.") ; Invalid userid/password etc.
  Exit
Endif
If _AD_IsMemberOf("Group") = 1 Then
  MsgBox(0,"AD","User is member of group xx")
  Exit
Endif
_AD_Close()

If you are running Windows 7 you get more information if the userid/password is invalid, account is locked etc.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

For the current user this would look like:

#include <AD.au3>
If _AD_Open() <> 1 Then
  MsgBox(0,"AD","Error " & @error " returned by _AD_Open.") ; Invalid userid/password etc.
  Exit
Endif
If _AD_IsMemberOf("Group") = 1 Then
  MsgBox(0,"AD","User is member of group xx")
  Exit
Endif
_AD_Close()

If you are running Windows 7 you get more information if the userid/password is invalid, account is locked etc.

Thanks, I was thinking about that last night some how using _AD_Open and _AD_IsMemberOf. It will be running on XP but will have to play around with those functions and see what I get out of them.

Share this post


Link to post
Share on other sites

For the current user this would look like:

#include <AD.au3>
If _AD_Open() <> 1 Then
  MsgBox(0,"AD","Error " & @error " returned by _AD_Open.") ; Invalid userid/password etc.
  Exit
Endif
If _AD_IsMemberOf("Group") = 1 Then
  MsgBox(0,"AD","User is member of group xx")
  Exit
Endif
_AD_Close()

If you are running Windows 7 you get more information if the userid/password is invalid, account is locked etc.

Water - Question for you. I am running this under WinXP. _AD_Open ( "Username", "Password")

If I use this with the correct password or wrong password, I receive a value of Success - 1 and @error of 0. Is that because I am running this under WinXP?

Share this post


Link to post
Share on other sites

Is that because I am running this under WinXP?

Correct. Windows XP is not very good in returning useful error information.

You can either use the test version of the enhanced _AD_Open. Or you can wait for version 0.40 of the UDF which will be released in the next 2-3 weeks.

Both functions set @error = 8 on Windows XP if the userid or password is invalid.

On Windows 7 you get an error array and @error is set to the Windows32 error code of the last LDAP function call.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Correct. Windows XP is not very good in returning useful error information.

You can either use the test version of the enhanced _AD_Open. Or you can wait for version 0.40 of the UDF which will be released in the next 2-3 weeks.

Both functions set @error = 8 on Windows XP if the userid or password is invalid.

On Windows 7 you get an error array and @error is set to the Windows32 error code of the last LDAP function call.

Thanks water, That test version worked for me.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0