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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
<%@ Page Language="VB" %>
<%@ import Namespace="System.DirectoryServices" %>
<script runat="server">
' Insert page code here
'
Sub Page_Load()
If Not Page.IsPostBack then
Try
'Si aucune donnée n'est transmise alors On met un texte par défaut
'If (PreviousPage Is Nothing) Then
'RecupData.Text = "Rien à afficher"
'Else
Dim DropDownList1 As DropDownList = Ctype(PreviousPage.FindControl("DropDownList1") , DropDownList)
Dim log as string
Dim Ldap As DirectoryEntry = new DirectoryEntry("LDAP://ou="+DropDownList1.SelectedValue+",dc=tamac,dc=local", "Administrator", "admin")
Dim searcher As DirectorySearcher = New DirectorySearcher (Ldap)
searcher.Filter = "(objectClass=user)"
Dim DirEntry As DirectoryEntry
response.write("<html>")
response.write("<head>")
response.write("</head>")
response.write("<body>")
response.write("<h1 align='center'> users for OU "+DropDownList1.SelectedValue+" </h1>")
response.write("<table width=60% align=center border=1>")
response.write("<tr><td>Login</td><td>Nom</td></tr>")
For Each result As SearchResult In searcher.FindAll
Dim login as string
Dim nom as string
'On récupère l'entrée trouvée lors de la recherche
DirEntry = result.GetDirectoryEntry
login = DirEntry.Properties("SAMAccountName").Value.ToString()
nom = DirEntry.Properties("Name").Value.ToString()
response.write("<tr>")
response.write("<td>"+login+"</td>")
response.write("<td>"+nom+"</td>")
response.write("<td><a href='enabled_user.aspx?log="+login+"'>Enabled</a></td>")
response.write("<td><a href='desabled_user.aspx?log="+login+"'>Desabled</a></td>")
'response.write("<td><a href='delete_user.aspx?log="+login+"&DropDownList1="+DropDownList1.SelectedValue+"'>Delete</a></td>")
'response.write("<td><a href='delete_user.aspx?log="+login+"'>Delete</a></td>")
response.write("</tr>")
'DropDownList2.Items.Add(DirEntry.Properties("SAMAccountName").Value.ToString())
Next
response.write("</table>")
response.write("</body>")
response.write("</html>")
Catch Ex As Exception
response.write(Ex.Message)
End Try
response.write("<a href='ou_selected3.aspx'>Back</a>")
response.write("</br>")
response.write("<a href='manage_all.aspx'>Manage all users by OU</a>")
response.write("</br>")
'response.write("<a href='manage_group_all.aspx'>Manage all users by group</a>")
End If
End Sub
'Sub Button1_Click(sender As Object, e As EventArgs)
'Try
' on se connecte au domaine tamac.local
'Dim Ldap As New DirectoryEntry("LDAP://tamac.local", "Administrateur", "admin")
'Dim Ldap As DirectoryEntry = new DirectoryEntry("LDAP://ou="+TextBox1.Text+",dc=tamac,dc=local", "Administrateur", "admin")
' on instancie la méthode DirectorySearcher
'Dim searcher As DirectorySearcher = New DirectorySearcher (Ldap)
'on définit un filtre sur l'attribu sAMAccount, à savoir le login du compte à désactiver
'searcher.Filter = "(sAMAccountName="+TextBox2.Text+")"
'J'instancie l'objet MonUser en tant que DirectoryEntry
'Dim MonUser As DirectoryEntry
'J'effectue une boucle qui va me permettre de récupérer le résultat correspondant au filtre ci-dessus
'For each result As SearchResult In searcher.FindAll
'MonUser = result.GetDirectoryEntry
'Ldap.Children.Remove(MonUser)
'response.redirect("ou_selected3.aspx")
'Next
'Catch Ex As Exception
'response.write(Ex.Message)
'End Try
'End Sub
</script>
<html>
<head>
</head>
<body>
<form id="Form1" runat="server">
<div><asp:Label id="RecupData" runat="server" text="Label"></asp:Label>
</div>
<div align="center">
</div>
<strong><font size="6"></font></strong>
<div align="center">
</div>
<div align="center">
</div>
<div align="center">
</div>
<!-- Insert content here -->
</form>
</body>
</html> |
Partager