使用LDAP验证用户 [英] Authenticating User using LDAP

查看:108
本文介绍了使用LDAP验证用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个要求,我需要使用他的LDAP用户名和密码对用户进行身份验证,一旦用户通过身份验证,我想添加用户对XML标记的凭据,以便下次考虑性能时登录可能更加独特。我已经搜索了几个线程但是我仍然有点困惑如何接近这个。

任何人都可以给我任何关于它的想法吗?

谢谢!

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 !

推荐答案

以下代码用于LDAP身份验证。

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
        Try
            Dim Results As System.DirectoryServices.SearchResult = Searcher.FindOne
            Success = Not (Results Is Nothing)
        Catch
            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"
        Else
        lbl_msg.Text = "Login Failed"
        End If







以上代码非常快,我认为你不需要存储它在XML中,而且,大多数ActiveDirectory服务都使用密码expira因此,如果担心安全问题,则在每次登录时进行身份验证。




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.


这篇关于使用LDAP验证用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆