Public Shared Function Authenticate(ByVal domain As String, ByVal username As String, ByVal password As String) As Boolean
Dim bAuth As Boolean = False
Dim entry As DirectoryEntry = Nothing
Try
'Objet de notre utilisateur de la hiérarchie Active Directory.
entry = New DirectoryEntry("LDAP://" & domain, username, password)
'Obtient l'objet ADSI natif.
Dim NativeObject As Object = entry.NativeObject
bAuth = True
Catch ex As Exception
bAuth = False
Finally
'Libère les ressources
entry.Close()
entry.Dispose()
End Try
Return bAuth