Lew Posted August 31, 2010 Share Posted August 31, 2010 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. Link to comment Share on other sites More sharing options...
rvn Posted August 31, 2010 Share Posted August 31, 2010 search the forum first Link to comment Share on other sites More sharing options...
Lew Posted August 31, 2010 Author Share Posted August 31, 2010 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. :) Link to comment Share on other sites More sharing options...
water Posted August 31, 2010 Share Posted August 31, 2010 (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 August 31, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Lew Posted August 31, 2010 Author Share Posted August 31, 2010 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. Link to comment Share on other sites More sharing options...
water Posted August 31, 2010 Share Posted August 31, 2010 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Lew Posted August 31, 2010 Author Share Posted August 31, 2010 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. Link to comment Share on other sites More sharing options...
Lew Posted September 1, 2010 Author Share Posted September 1, 2010 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? Link to comment Share on other sites More sharing options...
water Posted September 1, 2010 Share Posted September 1, 2010 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Lew Posted September 1, 2010 Author Share Posted September 1, 2010 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now