Jump to content

Active Directory UDF


water
 Share

Recommended Posts

According to MS System Error Codes this means:

ERROR_LOGON_FAILURE The user name or password is incorrect. 1326 (0x52E)

How do you enter the username?

  • Windows Login Name e.g. "DJ"
  • NetBIOS Login Name e.g. "<DOMAIN>\DJ"
  • User Principal Name e.g. "DJ@domain.com"

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Which version of the UDF and which operating system do you run?

I am using version 1.2.0

Windows 7 64-bit(program also runs in 64-bit.

According to MS System Error Codes this means:

ERROR_LOGON_FAILURE The user name or password is incorrect. 1326 (0x52E)

How do you enter the username?

  • Windows Login Name e.g. "DJ"
  • NetBIOS Login Name e.g. "<DOMAIN>DJ"
  • User Principal Name e.g. "DJ@domain.com"

Windows login name: "Akarillon"

EDIT: When I use the other method that worked, it goes straight past the @error and into the next MsgBox even when the username and password is "Username" and "Password"

Edited by Akarillon

Challenge accepted!

Link to comment
Share on other sites

Could you try

_AD_Open(@LogonDomain & "" & $Username, $Password)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

How about

_AD_Open()

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

The problem is that $username and $password are referencing labels, not your inputs, plus you're not using GUICtrlRead on the $username and $password, you're just passing the handles to the ADOpen command.

;your code
GUICtrlCreateInput("Username", 112, 24, 121, 21)
GUICtrlCreateInput("Password", 112, 64, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$Username = GUICtrlCreateLabel("Username", 24, 24, 52, 17)
$Password = GUICtrlCreateLabel("Password", 24, 64, 50, 17)

How it should be written

$Username = GUICtrlCreateInput("Username", 112, 24, 121, 21)
$Password = GUICtrlCreateInput("Password", 112, 64, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
GUICtrlCreateLabel("Username", 24, 24, 52, 17)
GUICtrlCreateLabel("Password", 24, 64, 50, 17)
; more code

_ADOpen(GUICtrlRead($username), GUICtrlRead($Password))

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This is because they are not used. If no parameters are used the credentials of the currently logged on user are passed.

Could you try to run the _AD_Open.au3 example script? If gives detailed error information when running on Windows 7.

Looks like BrewManNH found the problem :huh:

I was just concentrating on the AD part. :D

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

hey water =)

i was looking through the available functions in your udf, do you have the ability to do this (list active connections)?

http://gallery.technet.microsoft.com/scriptcenter/61539a7d-271e-421e-b7c3-2f4d99a77588

once again, thanks for working on this awesome udf!

Link to comment
Share on other sites

Sure. Shouldn't be to hard because it's written in VB.

How fast do you need it?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

whenever you can is cool - curious to see what the output would look like. (trying to find out where users are connected - especially if they have lingering connections)

wasn't sure how to translate it all (want to see what results will look like)

$strDcRDN   = "cn=atl-dc-01"
$strSiteRDN = "cn=Ga-Atl-Sales"

$objRootDSE = ObjGet("LDAP://RootDSE")
$strConfigurationNC = $objRootDSE.Get("configurationNamingContext")

$strNtdsSettingsPath = "LDAP://CN=NTDS Settings," & $strDcRDN & _
    ",cn=Servers," & $strSiteRDN & ",cn=Sites," & $strConfigurationNC
    
    
$objNtdsSettings = ObjGet($strNtdsSettingsPath)

$objNtdsSettings.Filter = Array("nTDSConnection") ;????
Edited by gcue
Link to comment
Share on other sites

If you want to see the results, copy the VB code to a file with extension .VBS and run it. Then you can tell if it is worth to translate the code to AutoIt.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

The script should look like:

Global $strDcRDN = "cn=atl-dc-01" - Your Domain Server
Global $strSiteRDN = "cn=Ga-Atl-Sales" - Your Site name
Global $objRootDSE = ObjGet("LDAP://RootDSE")
Global $strConfigurationNC = $objRootDSE.Get("configurationNamingContext")
Global $strNtdsSettingsPath = "LDAP://CN=NTDS Settings," & $strDcRDN & _
        ",cn=Servers," & $strSiteRDN & ",cn=Sites," & $strConfigurationNC
Global $objNtdsSettings = ObjGet($strNtdsSettingsPath)
Global $aFilter[1] = ["nTDSConnection"]
$objNtdsSettings.Filter = $aFilter
ConsoleWrite($strDcRDN & " NTDS Connection Objects" & @CRLF & @CRLF)

For $objConnection In $objNtdsSettings
    ConsoleWrite("Name:   " & $objConnection.Name & @CRLF)
    ConsoleWrite("Enabled:   " & $objConnection.enabledConnection & @CRLF)
    ConsoleWrite("From:   " & $objConnection.fromServer & @CRLF) ;Split(objConnection.fromServer, ",")(1)
    ConsoleWrite("Options:   " & $objConnection.Options & @CRLF)
    ConsoleWrite("Transport: " & $objConnection.transportType & @CRLF) ; Split(objConnection.transportType, ",")(0)
    ConsoleWrite(@CRLF & "Naming Contexts" & @CRLF)
    ConsoleWrite("---------------" & @CRLF)
    For $objDNWithBin In $objConnection.GetEx("ms-DS-ReplicatesNCReason")
        ConsoleWrite($objDNWithBin.DNString & @CRLF)
    Next
Next

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

sorry water - had to leave early day before yesterday and had yesterday off! =)

i wasn't able to get it to work.. i think this is querying for sites? i think id want it to query for user object and see where the user is connected. is there something else i can use for users instead of cn=sites ?

Link to comment
Share on other sites

The script returns replication connections.

What do you exactly want to do?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

what i want it to do is return computernames or ip addresses of where a user object is connected

so feed it a sAMAccountName and return where its actively connected.

found this other one but not sure if its returning active connections or just accounts on the domain

http://ss64.com/vb/syntax-ad.html

Edited by gcue
Link to comment
Share on other sites

"where a user object is connected" what does this mean?

The DC the computer used to login to the domain?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Can't be done using the UDF. We use the logon script here to store this information on a fileserver.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...