1. <small id='YJg7C'></small><noframes id='YJg7C'>

    2. <legend id='YJg7C'><style id='YJg7C'><dir id='YJg7C'><q id='YJg7C'></q></dir></style></legend>
        <bdo id='YJg7C'></bdo><ul id='YJg7C'></ul>

      <i id='YJg7C'><tr id='YJg7C'><dt id='YJg7C'><q id='YJg7C'><span id='YJg7C'><b id='YJg7C'><form id='YJg7C'><ins id='YJg7C'></ins><ul id='YJg7C'></ul><sub id='YJg7C'></sub></form><legend id='YJg7C'></legend><bdo id='YJg7C'><pre id='YJg7C'><center id='YJg7C'></center></pre></bdo></b><th id='YJg7C'></th></span></q></dt></tr></i><div id='YJg7C'><tfoot id='YJg7C'></tfoot><dl id='YJg7C'><fieldset id='YJg7C'></fieldset></dl></div>

      <tfoot id='YJg7C'></tfoot>

        ldapjs 身份验证(用户登录设置)

        ldapjs authentification (user login setup)(ldapjs 身份验证(用户登录设置))

        <small id='oLR8Y'></small><noframes id='oLR8Y'>

              <tbody id='oLR8Y'></tbody>
            <legend id='oLR8Y'><style id='oLR8Y'><dir id='oLR8Y'><q id='oLR8Y'></q></dir></style></legend>
            <tfoot id='oLR8Y'></tfoot>
            • <bdo id='oLR8Y'></bdo><ul id='oLR8Y'></ul>

                • <i id='oLR8Y'><tr id='oLR8Y'><dt id='oLR8Y'><q id='oLR8Y'><span id='oLR8Y'><b id='oLR8Y'><form id='oLR8Y'><ins id='oLR8Y'></ins><ul id='oLR8Y'></ul><sub id='oLR8Y'></sub></form><legend id='oLR8Y'></legend><bdo id='oLR8Y'><pre id='oLR8Y'><center id='oLR8Y'></center></pre></bdo></b><th id='oLR8Y'></th></span></q></dt></tr></i><div id='oLR8Y'><tfoot id='oLR8Y'></tfoot><dl id='oLR8Y'><fieldset id='oLR8Y'></fieldset></dl></div>
                  本文介绍了ldapjs 身份验证(用户登录设置)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我目前正在运行 node.js,它安装了 ldapjs. 我的目标是拥有一个使用 ldapjs 的系统,允许用户使用用户名和密码登录.

                  So I'm currently running node.js, which has ldapjs installed. My aim is to have a system that uses ldapjs to allow users to login with a username and password.

                  我已经阅读 http://ldapjs.org 文档有一段时间了,但我很难理解整个文档ldap 的想法和 ldapjs 的实现.

                  I have been reading over the http://ldapjs.org documentation for awhile now but am struggling to understand the whole idea of ldap and ldapjs's implementation of it.

                  我目前从文档中得到这个

                  I currently have this from the documentation

                  var ldap = require('ldapjs');
                  
                  var server = ldap.createServer();
                  
                  server.bind('cn=root', function(req, res, next) {
                    if (req.dn.toString() !== 'cn=root' || req.credentials !== 'secret')
                      return next(new ldap.InvalidCredentialsError());
                  
                    res.end();
                    return next();
                  });
                  
                  server.listen(1389, function() {
                    console.log('LDAP server up at: %s', server.url);
                  });
                  

                  这使我可以运行以下内容并成功绑定到服务器.

                  Which allows me to run the below and successfully bind to the server.

                  ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" objectclass=*
                  

                  但我真的不确定从这里去哪里,或者即使这是正确的方法......

                  But I'm really unsure of where to go from here or even if this is the correct approach...

                  理想的设置是拥有一系列用户和密码,并在成功的 ldap 连接上确认详细信息正确并以 true 响应,如果用户名/密码不正确则返回 false.

                  The ideal setup would be to have a range of users and passwords, and on a successful ldap connection confirm the details are correct and respond with a true, or false if the username/pass was incorrect.

                  有没有人知道有什么好的资源可以找到更多关于这方面的信息,或者更好的是可以建议一些基本的客户端/服务器端代码,让我知道下一步该去哪里!

                  Does anyone know of any good resources for finding out more about this, or better yet can suggest some basic client/server side code to give me an idea of where to go next!

                  任何回复将不胜感激.

                  非常感谢

                  推荐答案

                  我没用过ldapjs,但是根据我刚刚在其看似不完整的文档中快速阅读的内容,它可以用来实现LDAP服务器或LDAP客户端,这似乎是您正在尝试做的事情(即,我假设您想根据现有的 LDAP 服务器对应用程序中的用户进行身份验证).其文档中的大多数示例都集中在创建一个侦听某个端口并与后端数据库交互的 LDAP 服务器.如果您不想在后端数据库或用户和密码存储之间放置基于 LDAP 的接口,那么您可能不需要服务器 API.如果您已经运行了一个 LDAP 服务器,那么您将需要使用它的客户端 API 来执行以下操作:

                  I never used ldapjs, but based on what I just quickly read in its seemingly incomplete document, it can be used to implement an LDAP server or an LDAP client, which seems to be what you're trying to do (i.e., I'm assuming you want to authenticate users in your application against an existing LDAP server). Most of the examples in its document focus on creating an LDAP server that listens on a certain port and interacts with a back-end database. If you're not trying to put an LDAP-based interface between your back-end database or store of users and passwords, then you probably don't need the server API. If you already have an LDAP server running, then you will need to use its client API to do something like this:

                  1.匿名绑定到提供目录服务(包括身份验证服务)的 LDAP 服务器.看起来你可以这样做:

                  1.Bind anonymously to the LDAP server that provides the directory services including the authentication services. It looks like you can just do this with:

                  var ldap = require('ldapjs');
                  var client = ldap.createClient({
                      url: 'ldap://my.ldap.server'
                  });
                  

                  2.通过用户名(例如,电子邮件地址)搜索相应条目的 DN

                  2.Search by the username (e.g., e-mail address) for the corresponding entry's DN

                  var opts = {
                    filter: '(mail=USERNAME)',
                    scope: 'sub'
                  };
                  
                  client.search('ou=users,o=acme.com', opts, function(err, res) {
                    assert.ifError(err);
                  
                    res.on('searchEntry', function(entry) {
                      console.log('entry: ' + JSON.stringify(entry.object));
                    });
                    res.on('searchReference', function(referral) {
                      console.log('referral: ' + referral.uris.join());
                    });
                    res.on('error', function(err) {
                      console.error('error: ' + err.message);
                    });
                    res.on('end', function(result) {
                      console.log('status: ' + result.status);
                    });
                  });
                  

                  3.获取返回条目的 DN (entry.object).这个库的文档并没有过多地讨论如何使用这些对象(例如,它们的方法、属性等是什么).因此,您必须弄清楚如何实际获取您刚刚从目录服务器检索到的条目的 DN 或字符串表示形式.[请参阅此答案下方的评论]

                  3.Grab the DN of the returned entry ( entry.object ). The documentation of this library doesn't talk much about how these objects can be used (e.g., what their methods, properties, etc. are). So, you will have to figure out how to actually get the DN or string representation of the DN of the entry you just retrieved from the directory server. [See the comment(s) below this answer]

                  4.使用该DN重新绑定到服务器:

                  4.Rebind to the server using that DN:

                  client.bind(DN_RETRIEVED, PASSWORD_USER_ENTERED, function(err) {
                    assert.ifError(err);
                  });
                  

                  5.上面绑定的结果是你需要用来判断认证是否成功的.

                  5.The result of the bind above is what you will need to use to determine whether or not the authentication was successful.

                  如果您尝试在您的用户/密码数据存储之前实现一个 LDAP 服务器以进行基于 LDAP 的身份验证,那么您将需要遵循他们的服务器示例.我个人认为这是一种矫枉过正的做法,并且在安全性方面可能存在问题.

                  If you are trying to implement an LDAP server in front of your user/password data store for LDAP-based authentication, then you will need to follow their server examples. I personally think this is an overkill and could be problematic in terms of security.

                  这篇关于ldapjs 身份验证(用户登录设置)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  quot;Status Code:200 OK (from ServiceWorker)quot; in Chrome Network DevTools?(“状态码:200 OK(来自 ServiceWorker)在 Chrome 网络开发工具中?)
                  How to set a header for a HTTP GET request, and trigger file download?(如何为 HTTP GET 请求设置标头并触发文件下载?)
                  Adding custom HTTP headers using JavaScript(使用 JavaScript 添加自定义 HTTP 标头)
                  SQL Query DocumentDB in Azure Functions by an integer not working(通过整数在 Azure Functions 中 SQL 查询 DocumentDB 不起作用)
                  Azure Functions [JavaScript / Node.js] - HTTP call, good practices(Azure Functions [JavaScript/Node.js] - HTTP 调用,良好实践)
                  Azure Functions - Import Custom Node Module(Azure Functions - 导入自定义节点模块)
                  <i id='Jkw2Y'><tr id='Jkw2Y'><dt id='Jkw2Y'><q id='Jkw2Y'><span id='Jkw2Y'><b id='Jkw2Y'><form id='Jkw2Y'><ins id='Jkw2Y'></ins><ul id='Jkw2Y'></ul><sub id='Jkw2Y'></sub></form><legend id='Jkw2Y'></legend><bdo id='Jkw2Y'><pre id='Jkw2Y'><center id='Jkw2Y'></center></pre></bdo></b><th id='Jkw2Y'></th></span></q></dt></tr></i><div id='Jkw2Y'><tfoot id='Jkw2Y'></tfoot><dl id='Jkw2Y'><fieldset id='Jkw2Y'></fieldset></dl></div>

                  <small id='Jkw2Y'></small><noframes id='Jkw2Y'>

                  <legend id='Jkw2Y'><style id='Jkw2Y'><dir id='Jkw2Y'><q id='Jkw2Y'></q></dir></style></legend>

                      <bdo id='Jkw2Y'></bdo><ul id='Jkw2Y'></ul>

                          <tbody id='Jkw2Y'></tbody>

                        1. <tfoot id='Jkw2Y'></tfoot>