Jump to content

Recommended Posts

Posted

On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")

Set objCommand = CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"

objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000

objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _

"SELECT ADsPath FROM 'LDAP://dc=put,dc=local' WHERE " & _

"objectCategory='organizationalUnit'"

Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF

Wscript.Echo objRecordSet.Fields("ADsPath").Value

objRecordSet.MoveNext

Loop

hi @ all,

this vbs is telling me all OUs with all sub OUs when i start it. Now i need this vbs full in autoit, but iam to stupid to convert it.

I need the Output from "Wscript.Echo objRecordSet.Fields("ADsPath").Value" in autoit to work with it.

Maybe i need to split or something? Thx 4 any help

Posted

The Output is:

; ----------------------------------------------------------------------------

;

; VBScript to AutoIt Converter v0.4

;

; ----------------------------------------------------------------------------

;#include <bk-logfile.au3>

;VA On Error Resume Next

Const $ADS_SCOPE_SUBTREE = 2

$objConnection = ObjCreate("ADODB.Connection")

$objCommand = ObjCreate("ADODB.Command")

$objConnection.Provider = "ADsDSOObject"

$objConnection.Open ("Active Directory Provider")

$objCommand.ActiveConnection = $objConnection

$objCommand.Properties("Page Size") = 1000

$objCommand.Properties("Searchscope") = $ADS_SCOPE_SUBTREE

$objCommand.CommandText = _

"SELECT ADsPath FROM 'LDAP://dc=put,dc=local' WHERE " & _

"objectCategory='organizationalUnit'"

$objRecordSet = $objCommand.Execute

$objRecordSet.MoveFirst()

Do Until $objRecordSet.EOF()

_WriteLog ($objRecordSet.Fields("ADsPath").Value)

$objRecordSet.MoveNext()

Loop

But the Error is

(28,4) : ERROR: syntax error

Do Until

~~~^

Posted

The Output is:

; ----------------------------------------------------------------------------

;

; VBScript to AutoIt Converter v0.4

;

; ----------------------------------------------------------------------------

;#include <bk-logfile.au3>

;VA On Error Resume Next

Const $ADS_SCOPE_SUBTREE = 2

$objConnection = ObjCreate("ADODB.Connection")

$objCommand = ObjCreate("ADODB.Command")

$objConnection.Provider = "ADsDSOObject"

$objConnection.Open ("Active Directory Provider")

$objCommand.ActiveConnection = $objConnection

$objCommand.Properties("Page Size") = 1000

$objCommand.Properties("Searchscope") = $ADS_SCOPE_SUBTREE

$objCommand.CommandText = _

"SELECT ADsPath FROM 'LDAP://dc=put,dc=local' WHERE " & _

"objectCategory='organizationalUnit'"

$objRecordSet = $objCommand.Execute

$objRecordSet.MoveFirst()

Do Until $objRecordSet.EOF()

_WriteLog ($objRecordSet.Fields("ADsPath").Value)

$objRecordSet.MoveNext()

Loop

But the Error is

(28,4) : ERROR: syntax error

Do Until

~~~^

hm so? it's an error

look in the help file for more info

Do

statements

...

Until <expression>

shold be somthing like this:

$i = 0
Do
    MsgBox(0, "Value of $i is:", $i)
    $i = $i + 1
Until $i = 10

hope i helped

Posted

Eek. That VBS converter has not been maintained recently and there have been HUGE changes to AutoIt since the last update:

Added v0.4 10.06.2005

Added v0.3 08.06.2005

Added v0.2 06.06.2005

Added v0.1 05.06.2005

Added v0.01 04.06.2005

This post has been edited by bkemmler: Jun 10 2005, 02:52 AM

That function looks useful to me, too. So give me a moment and I'll take a crack at it...

:)

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
Posted

Finished it. This works correctly on my 2003 AD domain controller:

Global Const $ADS_SCOPE_SUBTREE = 2

; Declare COM Object error handler:
Global $oComError = ObjEvent("AutoIt.Error", "_ComErrFunc")

; Create connection
$objConnection = ObjCreate("ADODB.Connection")
$objConnection.Provider = "ADsDSOObject"
$objConnection.Open ("Active Directory Provider")

; Set connection for command
$objCommand = ObjCreate("ADODB.Command")
$objCommand.ActiveConnection = $objConnection
$objCommand.Properties ("Page Size") = 1000
$objCommand.Properties ("Searchscope") = $ADS_SCOPE_SUBTREE
$objCommand.CommandText = "SELECT ADsPath FROM 'LDAP://dc=your, dc=domain, dc=com' WHERE " & _
        "objectCategory='organizationalUnit'"

; Execute the command
$objRecordSet = $objCommand.Execute

; Display results
$objRecordSet.MoveFirst
$Msg = ""
Do
    $Msg &= $objRecordSet.Fields ("ADsPath").Value & @LF
    $objRecordSet.MoveNext
Until $objRecordSet.EOF
MsgBox(64, "Results", $Msg)


;--------------------------------------
; Function _ComErrFunc()
;   Custom COM object error handler
;--------------------------------------
Func _ComErrFunc()
    Local $HexNumber = Hex($oComError.number, 8)
    MsgBox(16, "AutoIT COM Error Occured!", _
            @TAB & "Error Number: " & $HexNumber & @CRLF & _
            @TAB & "Line Number: " & $oComError.scriptline & @CRLF & _
            @TAB & "Description: " & $oComError.description & @CRLF & _
            @TAB & "WinDescription: " & $oComError.windescription)
    SetError(1); something to check for when this function returns
EndFunc   ;==>_ComErrFunc

Enjoy!

:)

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

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
  • Recently Browsing   0 members

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