Sign in to follow this  
Followers 0
davezub

COM - ADSysteminfo Object

4 posts in this topic

OK I have to admit I suck at WMI/VB scripting.....However, I'm digging through the stuff with all posts from sven and the help file. I already have a script that I grab the username and fullname (I can't use the Autoit macro @UserName because I'm running the job under a scheduler using the local system account). However, I now need to grab the OU the user is located, no big deal 4 lines of code (see below - works)

Set objInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objInfo.Username & "")
Set objUserParent = GetObject(objUser.Parent)
WScript.Echo objInfo.UserName
WScript.Echo objUserParent.distinguishedName

I tried to convert this to Autoit using the VB converter floating around - (see below) but it fails on ObjCreate.

#include <bk-logfile.au3>

$objInfo = ObjCreate("ADSystemInfo")
$objUser = ObjGet("LDAP://" & $objInfo.Username & "")
$objUserParent = ObjGet($objUser.Parent)
_WriteLog ($objInfo.UserName)
_WriteLog ($objUserParent.distinguishedName)

I read the help file and thought I would have to define the Object like it states in the help file "appname.objectype". So I follow the help file using OleView but the object does not seem to have the VersionIndependentProgId only ProgID = ADSysteminfo.

What am I doing wrong??????? Thanks....

Share this post


Link to post
Share on other sites



I think that you need to post the exact errors taht you receive. I don't get an error on the ObjCreate, so we'll need to see what you are getting.

Also, did you try executing the .vbs code and did it work as expected?

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

Share this post


Link to post
Share on other sites

I think that you need to post the exact errors taht you receive.  I don't get an error on the ObjCreate, so we'll need to see what you are getting.

Also, did you try executing the .vbs code and did it work as expected?

Dale

<{POST_SNAPBACK}>

Try this for error:

$objInfo = ObjCreate("ADSystemInfo")
ConsoleWrite($objInfo.Username & @LF)
$s_name = StringMid($objInfo.Username,4,StringInStr($objInfo.Username," ") - 4)
$objUser = ObjGet("LDAP://" & $objInfo.Username & "")
if @error then 
  Msgbox (0,"LDAP Test","Error Getting an LDAP Object. Error code: " & hex(@error,8))
  exit
endif
$objUserParent = ObjGet($objUser.Parent)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thanks, all, it works now it was a problem with the _WriteLog lines, I just whacked them and took out the include......

Thanks again......

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