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
            Dim Results As System.DirectoryServices.SearchResult = Searcher.FindOne
            Success = Not (Results Is Nothing)
            Success = False
        End Try
        Return Success
    End Function
dflynn21Director of ITAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In your project, add a reference to System.DirectoryServices. Then in you code file put the top line as:
Imports System.DirectoryServices

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dflynn21Director of ITAuthor Commented:
Works like a charm.. Thanks!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.