Click here to Skip to main content
12,945,066 members (56,629 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi All,

I have a requirement where I need to authenticate a user using his LDAP username and password and once the user is authenticated I want to add the credentials of the user to a XML tag so that next time the log in can be more unique considering the performance. I have search several threads on it however I am still bit confused how to approach towards this.
Can anyone please give me any idea regarding the same ?
Thank you !
Posted 7-Feb-13 20:16pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The below code is for the LDAP authentication.
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

Pass the required variable s as below
  If ValidateActiveDirectoryLogin("DOMAINNAME", Login1.UserName, Login1.Password) Then
        'do something
          Label1.Text = "Pass"
        lbl_msg.Text = "Login Failed"
        End If

The above code is quite fast, I dont think you would require to store it in XML and moreover, most of the ActiveDirectory services use a password expiration, so if security is a concern then authenticate on every login.
Taresh Uppal 11-Feb-13 7:06am
Actually Ineeded the XML coz there will be two kinds of user..One having read only access to my app and other having read and write both. So to check the users of each kind I need to keep one of the user's data into the xml on the project itself So that I can differentiate easily and make my choices according to it.
Anyways thanx for the link. It worked for me and I have coded the xml part too. Thanx again !
joe_j 11-Feb-13 10:05am
your welcome and happy that it helped you. happy coding

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 4,781
CHill60 3,135
Maciej Los 2,443
Jochen Arndt 1,910
ppolymorphe 1,765

Advertise | Privacy | Mobile
Web01 | 2.8.170518.1 | Last Updated 8 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100