NiTrOuS Posté(e) le 23 février 2006 Partager Posté(e) le 23 février 2006 Bonjour, je suis occupé à faire un site internet. Pour la sécurité, j'ai besoin de récupérer le nom du groupe auquel appartient l'utilisateur. Mais je n'y arrive pas! Voici mon code: Imports System.DirectoryServices Imports System.Data.SqlClient Imports System.Text Imports System.Collections Public Class index Inherits System.Web.UI.Page #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Protected WithEvents lLogin As System.Web.UI.WebControls.Label Protected WithEvents tblogin As System.Web.UI.WebControls.TextBox Protected WithEvents lPassword As System.Web.UI.WebControls.Label Protected WithEvents tbpassword As System.Web.UI.WebControls.TextBox Protected WithEvents lDomaine As System.Web.UI.WebControls.Label Protected WithEvents tbDomaine As System.Web.UI.WebControls.TextBox Protected WithEvents bLogin As System.Web.UI.WebControls.Button Protected WithEvents lNom As System.Web.UI.WebControls.Label Protected WithEvents lPrenom As System.Web.UI.WebControls.Label Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm Protected WithEvents lError As System.Web.UI.WebControls.Label 'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Public Function Log(ByVal username As String, ByVal password As String) Dim nom, prenom, test, jour, mois, annee, heure, minute, seconde As String Dim compteur As Integer Dim datenow As String Dim MyConnection As SqlConnection Try Dim path As String = "LDAP://192.168.81.128" Dim entry As DirectoryEntry = New DirectoryEntry(path, username, password) Dim searcher As DirectorySearcher = New DirectorySearcher(entry) searcher.Filter = "(SAMAccountName=" & username & ")" Dim result As SearchResult result = searcher.FindOne() entry = result.GetDirectoryEntry searcher.PropertiesToLoad.Add("memberOf") test = Trim(CStr(result.Properties("membreOf")(0))) System.Diagnostics.Debug.WriteLine("Le groupe est: " & test) Log = True Catch e As Exception System.Diagnostics.Debug.WriteLine("Erreur lors de la recherche: ") System.Diagnostics.Debug.WriteLine(e) Log = False End Try End Class L'erreur est: Object reference not set to an instance of an object. Lien vers le commentaire Partager sur d’autres sites More sharing options...
Messages recommandés
Archivé
Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.