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

        • <bdo id='M7WYZ'></bdo><ul id='M7WYZ'></ul>

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

        <i id='M7WYZ'><tr id='M7WYZ'><dt id='M7WYZ'><q id='M7WYZ'><span id='M7WYZ'><b id='M7WYZ'><form id='M7WYZ'><ins id='M7WYZ'></ins><ul id='M7WYZ'></ul><sub id='M7WYZ'></sub></form><legend id='M7WYZ'></legend><bdo id='M7WYZ'><pre id='M7WYZ'><center id='M7WYZ'></center></pre></bdo></b><th id='M7WYZ'></th></span></q></dt></tr></i><div id='M7WYZ'><tfoot id='M7WYZ'></tfoot><dl id='M7WYZ'><fieldset id='M7WYZ'></fieldset></dl></div>
        <tfoot id='M7WYZ'></tfoot>
      2. 从活动目录中读取 objectGUID

        Read objectGUID from active directory(从活动目录中读取 objectGUID)

            • <bdo id='c4w0B'></bdo><ul id='c4w0B'></ul>
                <tbody id='c4w0B'></tbody>

                <legend id='c4w0B'><style id='c4w0B'><dir id='c4w0B'><q id='c4w0B'></q></dir></style></legend>
                <i id='c4w0B'><tr id='c4w0B'><dt id='c4w0B'><q id='c4w0B'><span id='c4w0B'><b id='c4w0B'><form id='c4w0B'><ins id='c4w0B'></ins><ul id='c4w0B'></ul><sub id='c4w0B'></sub></form><legend id='c4w0B'></legend><bdo id='c4w0B'><pre id='c4w0B'><center id='c4w0B'></center></pre></bdo></b><th id='c4w0B'></th></span></q></dt></tr></i><div id='c4w0B'><tfoot id='c4w0B'></tfoot><dl id='c4w0B'><fieldset id='c4w0B'></fieldset></dl></div>
              1. <small id='c4w0B'></small><noframes id='c4w0B'>

                • <tfoot id='c4w0B'></tfoot>
                  本文介绍了从活动目录中读取 objectGUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试使用 node.js 从 AD 获取信息.我已经尝试过 activedirectoryldapauth-fork 并且通常代码可以工作,但是如果我需要一些 octetstring 数据,例如 objectGUID,我在对象中看到一个垃圾字符串.我发现二进制数据被转换成utf-8的字符串.但问题是数据在转换过程中被损坏(很多带有 65533 代码的 cahrs),我无法将字符串恢复为原始二进制文件.

                  I'm trying to get information from AD using node.js. I've tried activedirectory and ldapauth-fork and in general the code works, but if I need some octetstring data like objectGUID, I see a rubbish string in the object. I found that binary data is converted into a string as utf-8. But the problem is that the data is damaged during convertion (a lot of cahrs with 65533 code) and I can't revert the string to original binary.

                  如何访问 octetstring 格式的数据以获得正确的二进制表示?

                  How can I access data in octetstring format to get correct binary representation?

                  const ActiveDirectory = require('activedirectory');
                  
                  const config = {
                    url: 'LDAP://ldap.example.com',
                    baseDN: 'OU=Users,DC=example,DC=com',
                    username: 'user@example.com',
                    password: 'password'
                  };
                  
                  const ad = new ActiveDirectory(config);
                  
                  const query = { 
                    filter: '(objectClass=user)',
                    attributes: ["dn", "cn", "objectGUID", "objectSid"]
                  };
                  
                  ad.findUsers(query, function (err, result) {
                    if (err) {
                      return console.error(err);
                    }
                  
                    console.log(result.length);
                    console.log(result[0]); // objectGUID contains rubbish
                    console.log([...result[0].objectGUID].map(ch => ch.charCodeAt(0)));
                  });
                  

                  相关:

                  • https://github.com/mcavage/node-ldapjs/issues/228
                  • https://github.com/gheeres/node-activedirectory/pull/15

                  推荐答案

                  entryParser 就是为了这个目的:

                  const ActiveDirectory = require('activedirectory');
                  
                  const config = {
                    url: 'LDAP://ldap.example.com',
                    baseDN: 'OU=Users,DC=example,DC=com',
                    username: 'user@example.com',
                    password: 'password',
                    entryParser(entry, raw, callback) {
                      if (raw.hasOwnProperty("objectGUID")) { entry.objectGUID = raw.objectGUID; }
                      callback(entry);
                    }
                  };
                  
                  const ad = new ActiveDirectory(config);
                  
                  const query = { 
                    filter: '(objectClass=user)',
                    attributes: ["dn", "cn", "objectGUID", "objectSid"]
                  };
                  
                  ad.findUsers(query, function (err, result) {
                    if (err) {
                      return console.error(err);
                    }
                  
                    console.log(result.length);
                    console.log(result[0]); // objectGUID contains Buffer with strange byte order
                    console.log(result[0].objectGUID
                      .toString('hex')
                      .replace(
                        /^(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)(..)$/,
                        "{$4$3$2$1-$6$5-$8$7-$10$9-$16$15$14$13$12$11}"
                      ).toUpperCase() // Normal guid, conversion could be moved into the parser
                    );
                  });
                  

                  这篇关于从活动目录中读取 objectGUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 - 导入自定义节点模块)
                    <tbody id='4RVdD'></tbody>

                    <small id='4RVdD'></small><noframes id='4RVdD'>

                  • <legend id='4RVdD'><style id='4RVdD'><dir id='4RVdD'><q id='4RVdD'></q></dir></style></legend>
                      <tfoot id='4RVdD'></tfoot>

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