Link to home
Start Free TrialLog in
Avatar of dflynn21
dflynn21Flag for United States of America

asked on

Authenication Code

I’m trying to add some AD authentication code to my application and am getting some errors such as:


Error      1      Type 'System.DirectoryServices.DirectoryEntry' is not defined.      
Error      2      Type 'System.DirectoryServices.DirectorySearcher' is not defined.
Error      3      Name 'DirectoryServices' is not declared.      
Error      4      Type 'System.DirectoryServices.SearchResult' is not defined.

Did they change this in VS2005?

Code found on the Net:

    Private Function ValidateActiveDirectoryLogin(ByVal Domain As String, ByVal Username As String, ByVal Password As String) As Boolean
        Dim Success As Boolean = False
        Dim Entry As New System.DirectoryServices.DirectoryEntry("LDAP://" & Domain, Username, Password)
        Dim Searcher As New System.DirectoryServices.DirectorySearcher(Entry)
        Searcher.SearchScope = DirectoryServices.SearchScope.OneLevel
        Try
            Dim Results As System.DirectoryServices.SearchResult = Searcher.FindOne
            Success = Not (Results Is Nothing)
        Catch
            Success = False
        End Try
        Return Success
    End Function
ASKER CERTIFIED SOLUTION
Avatar of MxTxL
MxTxL

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dflynn21

ASKER

Works like a charm.. Thanks!