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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
| <HTML>
<HEAD>
<TITLE>Application champs pour vizelia</TITLE>
<HTA:APPLICATION ID = 'champViz'>
</HEAD>
<body bgcolor="#FFFFD2" scroll="no">
<div id="comboboxDOU"></div>
<script language="VBScript">
' ----------------------------------------------------------
' Variables Globales et Constantes
' ----------------------------------------------------------
Dim objConnection, UO, objRootDSE, objConn, strFilter, objRS, strBase, strBase2
Dim str, strAttrs, strScope, objRSS, objConn2,utilisateur, strFilter2
' ----------------------------------------------------------'
' Corps du script
' ----------------------------------------------------------'
main
' ----------------------------------------------------------'
' Procédure MAIN
' ----------------------------------------------------------'
sub main
Set objRootDSE = GetObject("LDAP://rootDSE")
strBase = "<LDAP://" & "OU=Mairie," & objRootDSE.Get("defaultNamingContext") & ">;"
strFilter = "(objectCategory=OrganizationalUnit);"
strAttrs = "distinguishedName;" 'il sagit de la liste des champs souhaités séparés par des virgules
strScope = "SubTree" ' profondeur de la recherche
set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider" ' fournisseur de données
set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
objRS.MoveFirst
strComboBox = "<Select id=""Combo"" name=""Combo"">" & VbCrLf
strComboBox = strComboBox & "<option value=""" & "" & """>" & "" & "</option>" & VbCrLf
Do While Not objRS.EOF
str = ""
str = ExtraitListeG(objRS.Fields(0).Value, ",") ' pour ne récupérer que des 'truc de la forme ou=ssi et non ou=ssi,ou=mairie,dc=mairie,dc=lan
strComboBox = strComboBox & "<option value=""" & str & """>" & str & "</option>" & VbCrLf
objRS.MoveNext
Loop
strComboBox = strComboBox & "</select>"
document.all.comboboxDOU.innerHTML = strComboBox
objConn.close
End Sub
Function ExtraitListeG(Liste, Cherche) ' extrait le champ à gauche d'une ,
Dim pos
pos = InStr(Liste, Cherche)
If pos = 0 Then
ExtraitListeG = ""
Else
ExtraitListeG = Mid(Liste, pos)
ExtraitListeG = Left(Liste, Len(Liste) - Len(ExtraitListeG))
End If
End Function
'jusque la sa marche ^^, ici arrive les problémes
Sub combo_onchange ' quand une OU est selectionné dans la combobox
'strBase2 = "<LDAP://" & combo.value & "," & objRootDSE.Get("defaultNamingContext") & ">;"
dim objfichier, myfile
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 dn FROM 'LDAP://"& combo.value &",dc=mairie,dc=lan' WHERE objectCategory='user'" 'le probléme doit etre ici, 'enfin je pense, vu ke je ne comprend pas l'erreur
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
' Set objUser = GetObject(objRecordSet.Fields("dn").Value)
msgbox("toto")
objRecordSet.MoveNext
Loop
end sub
</script>
<span id = "testspan"></span>
<form name="TestForm">
<INPUT TYPE="Button" NAME="btnStart" VALUE="Start"><br>
</form>
</BODY>
</HTML> |
Partager