1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| 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=priv,dc=chu-tours,dc=fr' 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,Ligne, AR, AR1
Set WSHNetwork = CreateObject("WScript.Network")
Do While User = ""
' User = WSHNetwork.UserName
Loop
msgbox GetAdsPath(User) |
Partager