在使用LDAP验证之前先哈希密码 [英] Hash password before validate with LDAP

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

问题描述

我有一个基于Web的工具.在登录表单上,密码将在发送前经过哈希处理. 很好,数据库仅存储哈希密码.

I have a web-based-tool. On the login-form, the password will hashed before sending it. All fine, the database stores only hashed passwords.

现在,我们希望通过DirectoryEntry使用LDAP登录. 但是构造函数只接受普通密码.

Now, we want a login with LDAP over DirectoryEntry. But the constructor only accepts plain passwords.

我的问题:如何将哈希密码传递给DirectoryEntry -class?

My question: How can I pass hashed passwords to DirectoryEntry-class?

当前方法:

    public bool isAuthenticated(string domain, string username, string pwd)
    {
        string domainAndUsername = domain + @"\" + username;
        DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, pwd);

        try
        {
            Object obj = entry.NativeObject;
            return true;
        }
        catch
        {
            return false;
        }
    }

推荐答案

我不知道C#,但是就LDAP协议而言,无法使用已经散列的密码进行身份验证.

I do not know C#, but as far as LDAP protocol goes, there is no way to authenticate with an already hashed password.

为什么在传输密码之前需要对密码进行哈希处理?

Why do you need to hash the password before transmitting it?

如果要避免通过网络传输它,最容易使用的解决方案是通过SSL连接到LDAP目录.

If it is to avoid transmitting it over the network, the easiest solution to use would be to connect to the LDAP directory over SSL.

作为一个附带说明,IMO,传输散列密码的安全性不如清除密码安全.

As a side note, IMO, transmitting the hashed password is less secure than the clear one :

  • 如果攻击者拦截了该请求,则他将能够使用两种方式找到的数据进行身份验证
  • 如果攻击者成功转储了数据库并检索了哈希密码,如果他要做的只是传输该密码以进行身份​​验证,则将事实证明存储哈希密码的事实是无用的

编辑 :其他信息

Edit : Additionnal information

我不知道您使用的是哪个LDAP目录,但是在OpenLDAP上,如果不使用绑定操作,则可以实现这种机制(例如,您将无法使用密码策略覆盖).

I don't know which LDAP directory you use, but on OpenLDAP, you could implement this kind of mechanism if you don't use the bind operation (for example, you won't be able to use the password policy overlay).

您可以将 SASL代理授权实施为:

  • 使用技术帐户连接到目录
  • 搜索并检索尝试登录的条目用户
  • 如果提供的散列是存储的散列密码,则对自定义散列密码属性进行测试
  • 与另一个具有代理授权的技术帐户绑定,以充当该用户

它将使您仍然可以从ACL机制和日志记录系统中受益,以执行用户操作

It will allows you to still benefit from the ACL mechanism and logging system for users operations performed

但是:这仅在OpenLDAP上可用(或者如果另一个LDAP实现提供相同的机制),并且它实际上并不是LDAP协议的最新技术;)

BUT: This will be available only on OpenLDAP (or if another LDAP implemenation offer the same mechanism) and it is not really the most state of the art about the LDAP protocol ;)

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

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