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
|
<%@ Page Language="VB" %>
<%@ import Namespace="System.DirectoryServices" %>
<script runat="server">
' Insert page code here
'
Sub Page_Load()
if not page.ispostback then
try
' Définition de l'emplacement de recherche
Dim monEmplacementRecherche As New DirectoryEntry("LDAP://tamac.local", "Administrateur", "admin")
' Instanciation d'un objet DirectorySearcher
Dim maRecherche As New DirectorySearcher(monEmplacementRecherche)
' dureeMax initisalisée à 45 secondes
' Il s'agît de la durée maximale que prendra la requête
Dim dureeMax As New TimeSpan(0, 0, 45)
' Emplacement où la recherche doit être effectuée
' dans la hierarchie Active Directory
maRecherche.SearchRoot = monEmplacementRecherche
' Définition du Scope de la recherche, ici le conteneur
' seulement et tous ses "sous conteneur"
maRecherche.SearchScope = SearchScope.Subtree
' Filtre uniquement les objets de type "organizationalUnit"
maRecherche.Filter = "(objectClass=organizationalUnit)"
' Détermination de la propriété à récupérer lors de la recherche
maRecherche.PropertiesToLoad.Add("name")
' Durée maximum de la recherche
maRecherche.ServerTimeLimit = dureeMax
' Fixe le nombre maximum d'objets retournés
maRecherche.SizeLimit = 1500
Dim uneOU As DirectoryServices.SearchResult
response.write("<html>")
response.write("<head>")
response.write("</head>")
response.write("<body>")
response.write("<h1> Admin OU </h1>")
response.write("<table width=60% align=center border=1>")
response.write("<tr><td>Organizational Unit</td><td>Details</td></tr>")
' Récupération du 'sAMAccountName' des utilisateurs récupérés
For Each uneOU In maRecherche.FindAll()
Dim DirEntry As DirectoryEntry
Dim MyOU as string
DirEntry = uneOU.GetDirectoryEntry
MyOU= DirEntry.Properties("Name").Value.ToString()
response.write("<tr>")
response.write("<td>"+MyOU+"</td>")
response.write("<td><a href='details_ou.aspx?id="+MyOU+">Details</a></td>")
response.write("</tr>")
Next
response.write("</table>")
response.write("</body>")
response.write("</html>")
Catch Ex As Exception
response.write(Ex.Message)
End Try
End If
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<!-- Insert content here -->
</form>
</body>
</html> |
Partager