pascal huste Posted April 20, 2006 Share Posted April 20, 2006 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 nextDim objConnection, objCommand, objRecordSetGetAdsPath = ""Set objConnection = CreateObject("ADODB.Connection")objConnection.Open "Provider=ADsDSOObject;"Set objCommand = CreateObject("ADODB.Command")objCommand.ActiveConnection = objConnectionobjCommand.CommandText = "SELECT adspath FROM 'LDAP://dc=Unknow,dc=com' WHERE objectCategory='user' AND sAMAccountName='" & str_UserName & "'"Set objRecordSet = objCommand.Executeif (objRecordset.Fields("adspath") <> "") then GetAdsPath = objRecordset.Fields("adspath")end ifobjConnection.CloseErr.ClearOn error Goto 0End 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 ExplicitDim WSHNetwork, UserSet WSHNetwork = CreateObject("WScript.Network")Do While User = "" User = WSHNetwork.UserNameLoopUser = InputBox("Saisissez le login :", "Username", "")msgbox GetAdsPath(User) Link to comment Share on other sites More sharing options...
GaryFrost Posted April 20, 2006 Share Posted April 20, 2006 http://www.autoitscript.com/forum/index.php?showtopic=20736http://www.autoitscript.com/forum/index.php?showtopic=12281 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
randallc Posted April 20, 2006 Share Posted April 20, 2006 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 $nextLocal $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.Executeif ($objRecordSet.Fields("adspath") <> "") then $GetAdsPath = $objRecordSet.Fields("adspath")return $GetAdsPathEndIf$objConnection.Close();$Err.Clear();$On $error $Goto 0EndFunc;'************************************;'* 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 Explicitlocal $WSHNetwork, $User$WSHNetwork = ObjCreate("WScript.Network")While $User = ""$User = $WSHNetwork.UserNamewend$User = InputBox("Saisissez le login :", "Username", "")msgbox (0,"",_GetAdsPath($User))Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Developers Jos Posted April 20, 2006 Developers Share Posted April 20, 2006 Here is an example of a ldap query function.. to get you started.... SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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