【问题标题】:return user details after ldap authentication (asp.net vb)ldap 身份验证后返回用户详细信息(asp.net vb)
【发布时间】:2012-05-15 15:39:04
【问题描述】:

下午好! 我目前正在尝试为我的客户建立一个新的内部系统,他们坚持将登录与 AD 集成,这是有道理的,我已经成功地做到了这一点。

但是,在身份验证之后,我还想做的是将一些用户详细信息/属性存储为会话变量。

我有以下代码来验证用户:

'this function authenticates against AD - very simple and works nicely.
Function AuthenticateUser(path As String, user As String, pass As String) As Boolean
    Dim de As New DirectoryEntry(path, user, pass, AuthenticationTypes.Secure)
    Try
        'run a search using those credentials.  
        'If it returns anything, then you're authenticated
        Dim ds As DirectorySearcher = New DirectorySearcher(de)
        ds.FindOne()

        Return True
    Catch
        'otherwise, it will crash out so return false
        Return False
    End Try
End Function

效果很好,一旦函数返回 True,我将 Session("LoggedIn") 设置为 True。

我需要做的是(希望在上述函数中)保存用户的姓名,以及来自用户的 AD 配置文件中的其他 2 个自定义属性。

我将如何访问这些(假设)

【问题讨论】:

  • 我有相同的代码,但我无法让它工作。您可以提供任何机会和示例或您的参数是什么(让我们使用用户域 kevinland.org、用户 jeremy、密码骗子)

标签: asp.net vb.net active-directory ldap


【解决方案1】:

使用支持检索属性的DirectorySearcher 构造函数。将 LDAP 客户端所需的属性添加到构造函数中。

另见

【讨论】:

  • 您好特里,您是指 DirectoryServer 还是 DirectorySearcher?我在 .NET 4 中找不到对 DirectoryServer 的任何引用...
猜你喜欢
  • 1970-01-01
  • 2011-05-23
  • 2018-07-28
  • 2019-12-27
  • 2011-05-30
  • 1970-01-01
  • 2020-03-02
  • 2019-03-29
  • 1970-01-01
相关资源
最近更新 更多