Sign in to follow this  
Followers 0
pascal huste

Convert Vbs To Au3 (ldap Query)

4 posts in this topic

Hello.

please help me to convert this script.

thanks

'************************************

'* Nom de la fonction : GetAdsPath

'* Paramêtres : str_UserName

'* Retour : Chaine LDAP

'* Description : Retourne le chemin LDAP du compte utilisateur membre du domaine passé en paramêtre

'************************************

Function GetAdsPath(str_UserName)

On error resume next

Dim objConnection, objCommand, objRecordSet

GetAdsPath = ""

Set objConnection = CreateObject("ADODB.Connection")

objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")

objCommand.ActiveConnection = objConnection

objCommand.CommandText = "SELECT adspath FROM 'LDAP://dc=Unknow,dc=com' WHERE objectCategory='user' AND sAMAccountName='" & str_UserName & "'"

Set objRecordSet = objCommand.Execute

if (objRecordset.Fields("adspath") <> "") then

GetAdsPath = objRecordset.Fields("adspath")

end if

objConnection.Close

Err.Clear

On error Goto 0

End Function

'************************************

'* Nom de la fonction : Main()

'* Paramêtres : Aucun

'* Retour : Aucun

'* Description : Fonction principale > Affiche le chemin LDAP du compte utilisateur courrant

'************************************

'On error resume next

'Option Explicit

Dim WSHNetwork, User

Set WSHNetwork = CreateObject("WScript.Network")

Do While User = ""

User = WSHNetwork.UserName

Loop

User = InputBox("Saisissez le login :", "Username", "")

msgbox GetAdsPath(User)

Share this post


Link to post
Share on other sites



Hi,

This is close, using "vaconvert.au3" but not very useful;

Errors on "$objRecordSet = $objCommand.Execute"

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

;

; VBScript to AutoIt Converter v0.4

;

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

;adlogin.vbs

;'************************************

;'* Nom de la fonction : $GetAdsPath

;'* Paramêtres : $str_UserName

;'* Retour : Chaine LDAP

;'* Description : Retourne le chemin LDAP du compte utilisateur membre du domaine passé en paramêtre

;'************************************

func _GetAdsPath($str_UserName)

;$On $error $resume $next

Local $objConnection, $objCommand, $objRecordSet

$GetAdsPath = ""

$objConnection = ObjCreate("ADODB.Connection")

$objConnection.Open ("Provider=ADsDSOObject;")

$objCommand = ObjCreate("ADODB.Command")

$objCommand.ActiveConnection = $objConnection

$objCommand.CommandText = "SELECT adspath FROM 'LDAP://dc=Unknow,dc=com' WHERE objectCategory='user' AND sAMAccountName='" & $str_UserName & "'"

$objRecordSet = $objCommand.Execute

if ($objRecordSet.Fields("adspath") <> "") then

$GetAdsPath = $objRecordSet.Fields("adspath")

return $GetAdsPath

EndIf

$objConnection.Close()

;$Err.Clear()

;$On $error $Goto 0

EndFunc

;'************************************

;'* Nom de la fonction : Main()

;'* Paramêtres : Aucun

;'* Retour : Aucun

;'* Description : Fonction principale > Affiche le chemin LDAP du compte utilisateur courrant

;'************************************

;'On $error $resume $next

;'Option Explicit

local $WSHNetwork, $User

$WSHNetwork = ObjCreate("WScript.Network")

While $User = ""

$User = $WSHNetwork.UserName

wend

$User = InputBox("Saisissez le login :", "Username", "")

msgbox (0,"",_GetAdsPath($User))

Best, Randall

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