merci pour ton aide...
J'ai deja pensé a (re)declarer mon TextBox dans ma fonction mais le
compilateur m'indique qu'il est deja declaré...
voici mon code
Imports System.DirectoryServices
Public
Class WebForm1
Inherits System.Web.UI.Page
#
Region " Code généré par le Concepteur Web Form "
'Cet appel est requis par le Concepteur Web Form.
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
End Sub
Protected WithEvents DropDownList1 As System.Web.UI.WebControls.DropDownList
Protected WithEvents DropDownList2 As System.Web.UI.WebControls.DropDownList
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Table1 As System.Web.UI.WebControls.Table
'REMARQUE : la déclaration d'espace réservé suivante est requise par le Concepteur Web Form.
'Ne pas supprimer ou déplacer.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN : cet appel de méthode est requis par le Concepteur Web Form
'Ne le modifiez pas en utilisant l'éditeur de code.
InitializeComponent()
End Sub
#
End Region
Public ChaineConn As String = LDAP://monserver
Public LoginAD As String = "tata"
Public PasswordAD As String = "toto"
Public nbResult As Integer = 0
Public rootEntry As New DirectoryEntry(ChaineConn, LoginAD, PasswordAD)
Public Sub CherchePersonne(ByVal LeLogin As String)
' Cherche les Informations Sur le Compte suivant le Login Transmis
Dim searcher As New DirectorySearcher(rootEntry)
' Mettre ici les valeurs des différents attributs
searcher.PropertiesToLoad.Add("givenname")
''' nom
searcher.PropertiesToLoad.Add("sn")
''' prenom
searcher.PropertiesToLoad.Add("telephoneNumber")
''' telephone
searcher.PropertiesToLoad.Add("mail")
''' email
'searcher.Filter = "(&(anr=" & LeLogin & ")(objectCategory=person))"
searcher.Filter = "(&(objectCategory=person)(objectClass=user)(anr=" & LeLogin & "))"
Dim results As SearchResultCollection
results = searcher.FindAll()
nbResult = results.Count
If results.Count > 0 Then
Dim result As SearchResult
Dim Prop As ListItem
Dim N As Integer = 0
For Each result In results
Dim tmpRow As New TableRow
For N = 0 To searcher.PropertiesToLoad.Count - 1
Dim tmpCell As New TableCell
If Not (result.Properties(searcher.PropertiesToLoad.Item(N)) Is Nothing) Then
tmpCell.Text = Trim(
CStr(result.Properties(searcher.PropertiesToLoad.Item(N))(0)))
Else
tmpCell.Text = " "
End If
tmpRow.Cells.Add(tmpCell)
Next
Table1.Rows.Add(tmpRow)
Next
End If
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Dim L As New Integer
'Dim C As New Integer
'For L = 1 To 10
' Dim tmpRow As New TableRow
' For C = 1 To 5
' Dim tmpCell As New TableCell
' tmpCell.Text = L & "--" & C
' tmpRow.Cells.Add(tmpCell)
' Next
' Table1.Rows.Add(tmpRow)
'Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim obj As New WebForm1
obj.CherchePersonne(TextBox1.Text)
End Sub
End
Class