Jump to content

Prompt for AD Username and password


Recommended Posts

I see there is a Active Directory UDF and I see that Water is working on enhancements.  I would like to do something very simple  Prompt for a username, and password in a specific group.  If it passes authentication, great, if not, then exit.  But I do not understand where to start.

Link to comment
Share on other sites

  • Moderators

What are you trying to do with the authentication attempt (Open a file/dir, log into a remote machine, etc.)? Prompting for the username and password can be done easily enough with either a couple of InputBoxes or a small GUI, but the twist will come in what you're trying to accomplish (keeping in mind, as well, whatever lockout policies your domain has in place).

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

I'm not sure what enhancements Water is working on, but I have used this in the past to test for authentication. Again, be mindful of your corporate lockout policies.

pwCheck("Jim-Bob", "Password1", "myCompany.com")

Func pwCheck($Name, $Password, $Domain)
    Const $ADS_SECURE_AUTHENTICATION = 1

    $oAD = ObjGet("WinNT:").OpenDSObject("WinNT://" & $Domain, $Name, $Password, $ADS_SECURE_AUTHENTICATION)
        MsgBox(0, $Domain & "\" & $name, @error)
EndFunc

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

You would need to combine it with another function, such as _AD_IsMemberOf. I would suggest this (pseudo):

  • declare your vars (domain, username, pw, group)
  • call a single function passing those vars
  • Execute _AD_IsMemberOf first (if this fails, no need to test authentication and potentially lock the account)
  • If successful, move on to the next item.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

JLogan3o13 provided the perfect solution!

As I'm not working on any enhancements for the AD UDF at the moment there is only one way to check the userid/password. Pass the credentials to _AD_Open. With the enhanced error checking you can tell that the user provided a invalid passwort or whatever.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks for the feedback guys.  After looking over the UDFs, this is more trouble than its worth. 

Most UDFs are just one au3 file with several functions.  The AD zip I downloaded had 86 AU3 files in it.  One for every function.

 

I can simply create a password and code it into the app.

Edited by wisem2540
Link to comment
Share on other sites

  • Moderators

JLogan3o13 provided the perfect solution!

As I'm not working on any enhancements for the AD UDF at the moment there is only one way to check the userid/password. Pass the credentials to _AD_Open. With the enhanced error checking you can tell that the user provided a invalid passwort or whatever.

 

Geez, should have thought of that. So much more simple :>

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Most UDFs are just one au3 file with several functions.  The AD zip I downloaded had 86 AU3 files in it.  One for every function.

You only need AD.au3 in your script!

All other files are example scripts, help files etc.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

:)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...