water Posted August 10, 2010 Share Posted August 10, 2010 I use OpenDSObject to connect to the Active Directory. OpenDSObject needs the DC, username, password and flags as parameters.According to Microsoft "The IADsOpenDSObject method uses the default credentials when UserName and Password are set to NULL."How can I set a parameter to NULL?I searched the forum but all threads talk about DLLCall and neither of the solutions works. I tried "DEFAULT" , "", 0, 0x0 but always get an error message (Default gives 8002000F - parameter not optional, all other give 80020009 - Invalid username or password).I would be gratefull for any suggestions!Global $objDSO = ObjGet("LDAP:") Const $ADS_SERVER_BIND= 512 Global $username = "Domain\user" Global $username = "password" $obj1 = $objDSO.OpenDSObject("LDAP://DC.microsoft.com", $username, $password, $ADS_SERVER_BIND) 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...
PsaltyDS Posted August 10, 2010 Share Posted August 10, 2010 I don't know why "" doesn't work for null. But if you do provide the username, doesn't it need to be like this? Global $username = "cn=user,ou=users,dc=microsoft,dc=com" Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
ProgAndy Posted August 10, 2010 Share Posted August 10, 2010 I think the correct value would be Ptr(0), but up to now AutoIt doesn't support Pointers as COM-Parameters. This means, you can't skip username and password. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted August 10, 2010 Moderators Share Posted August 10, 2010 DaleHohm came up with a method using ScriptControl for NULL. Went something like: Global $o_vb_null = ObjCreate("ScriptControl") $o_vb_null.language = "VBScript" Global Const $NULL = $o_vb_null.eval("vbNullString") $o_vb_null = 0 Then you use $NULL where you need to. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
DaleHohm Posted August 10, 2010 Share Posted August 10, 2010 Here's a pointer to my writeup on this: http://www.autoitscript.com/forum/index.php?showtopic=64966&st=0&p=483555&hl=nothing&fromsearch=1&#entry483555 Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
water Posted August 11, 2010 Author Share Posted August 11, 2010 Hi guys, thanks a lot for the fast answers! I will have a look at them as soon as I find some spare time and post thre results. 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...
Richard Robertson Posted August 11, 2010 Share Posted August 11, 2010 I don't know why "" doesn't work for null.I am ashamed at you. You're an experienced user and should know the difference between null and an empty string. Link to comment Share on other sites More sharing options...
Bert Posted August 11, 2010 Share Posted August 11, 2010 Nobody is perfect. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
trancexx Posted August 11, 2010 Share Posted August 11, 2010 (edited) This works for me:expandcollapse popupGlobal $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Const $ADS_SERVER_BIND = 512 $sUserName = "" $sPassword = "" $objDSO = ObjGet("WinNT:") $oObject = $objDSO.OpenDSObject("WinNT://localhost/Administrators", $sUserName, $sPassword, $ADS_SERVER_BIND) ConsoleWrite("ADsPath:" & $oObject.ADsPath & @CRLF) ConsoleWrite("Class:" & $oObject.Class & @CRLF) ConsoleWrite("GUID:" & $oObject.GUID & @CRLF) ConsoleWrite("Name:" & $oObject.Name & @CRLF) ConsoleWrite("Parent:" & $oObject.Parent & @CRLF) ConsoleWrite("Schema:" & $oObject.Schema & @CRLF) ConsoleWrite("-------------------" & @CRLF) $sUserName = "trancexx" $sPassword = "MyRealPassword" $objDSO = ObjGet("WinNT:") $oObject = $objDSO.OpenDSObject("WinNT://localhost/Administrators", $sUserName, $sPassword, $ADS_SERVER_BIND) ConsoleWrite("ADsPath:" & $oObject.ADsPath & @CRLF) ConsoleWrite("Class:" & $oObject.Class & @CRLF) ConsoleWrite("GUID:" & $oObject.GUID & @CRLF) ConsoleWrite("Name:" & $oObject.Name & @CRLF) ConsoleWrite("Parent:" & $oObject.Parent & @CRLF) ConsoleWrite("Schema:" & $oObject.Schema & @CRLF) Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF) EndFuncSame results both for ("", "") and ("trancexx", "MyRealPassword"). Other random stuff produces errors. Edited August 11, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 11, 2010 Share Posted August 11, 2010 (edited) This works for me: ; ... $objDSO = ObjGet("WinNT:") $oObject = $objDSO.OpenDSObject("WinNT://localhost/Administrators", $sUserName, $sPassword, $ADS_SERVER_BIND) ;...Same results both for ("", "") and ("trancexx", "MyRealPassword"). Other random stuff produces errors. I think the issue is related to using the LDAP provider, and MSDN specifically warns against using .OpenDSObject() with the WinNT provider: Important: It is not recommended that you use this method with the WinNT Provider. For more information, please see KB article 218497, User Authentication Issues with the Active Directory Service Interfaces WinNT Provider. I am ashamed at you. You're an experienced user and should know the difference between null and an empty string. I can live with that, 'cause I'm still so pretty! Edited August 11, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
trancexx Posted August 11, 2010 Share Posted August 11, 2010 I think the issue is related to using the LDAP provider, and MSDN specifically warns against using .OpenDSObject() with the WinNT provider: For what that script was suppose to show I considered the 'WinNT' remark irrelevant.I still do.Why do you think it's only LDAP? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Bert Posted August 11, 2010 Share Posted August 11, 2010 (edited) I can live with that, 'cause I'm still so pretty! Ali may have something to say about that... Edited August 11, 2010 by MPH The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
water Posted August 12, 2010 Author Share Posted August 12, 2010 (edited) Thanks a lot for all the hints! After re-thinking my requirements I was able to eliminate the need for NULL in the OpenDSObject call But again, thank you very much for your efforts! Edited August 12, 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...
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