Bonjour,

Quelqu'un pourrait t'il ma'aider à convertir ce script VB en Perl, Merci d'avance pour votre aide.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
NumAGT =wscript.arguments.item(0)
 
 
 
wscript.echo recherchesimpleCN(NumAGT)
 
Function RechercheSimpleCN(Cible)
	Dim oRoot,ND,oC,oConnex,Collect,T_DN,Tab
	ServeurCible = "P99C"
	Tab = Split(Cible,",")
	Set oRoot = GetObject("LDAP://" & ServeurCible & ".cdif.dgi/RootDSE")
	ND = oRoot.Get("defaultNamingContext")
	Set oC = CreateObject("ADODB.Command")
	Set oConnex = CreateObject("ADODB.Connection")
	oConnex.Provider = "ADsDSOObject"
	oConnex.Open "Active Directory Provider"
	oC.ActiveConnection = oConnex
	oC.CommandText = "<LDAP://" & ND & ">;(CN=" & Tab(0) & ");distinguishedName,objectCategory;subtree"
	oC.Properties("Page Size") = 100
	oC.Properties("Timeout") = 30
	oC.Properties("Cache Results") = False
	Set Collect = oC.Execute
	If Collect.EOF Then
		RechercheSimpleCN = ""
	Else
		Do Until Collect.EOF
			T_DN = Collect.Fields("distinguishedName")
			Collect.MoveNext
		Loop
		RechercheSimpleCN = T_DN
	End If
	oConnex.Close
	Set Tab = nothing
	Set T_DN = nothing
	Set ND = Nothing
	Set oRoot = Nothing
	Set oC = Nothing
	Set oConnex = Nothing
	Set Collect = Nothing
End Function