Skip to content

.Net Authenticate User With Active Directory

January 6, 2012
    Public Shared Function AuthenticateUser(ByVal UserName As String, ByVal Password As String) As Boolean
        Dim Entry As New DirectoryEntry("LDAP://Test", UserName, Password)
        Dim Searcher As New DirectorySearcher(Entry)
        Searcher.SearchScope = SearchScope.OneLevel
        Try
            Dim Results As SearchResult = Searcher.FindOne
            AuthenticateUser = Not (Results Is Nothing)
        Catch
            AuthenticateUser = False
        End Try
    End Function
Advertisements

From → .Net

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: