Git Product home page Git Product logo

ldapjs-client-sync's Introduction

简介(Summary)

ldapjs-client-sync基于node-ldapjsClient API部分封装出Client API的同步方法,便于客户端逻辑的编写,避免回调地狱。

所有ldapjs-client-sync的API及API参数都可参考node-ldapjs官方文档

环境

开发环境:Node >= 12.21.0

安装(Install)

  • npm安装
npm i ldapjs-client-sync --save
  • cnpm安装
cnpm i ldapjs-client-sync --save

API

new LDAP()

返回一个LDAP实例,该实例为基于ldap.Client进行封装,添加了同步的方法。下文中所有的ldap都是指该LDAP类的实例,并非ldapjs中原生的ldap.Client实例。

该实例用于调用connect()方法。

示例:

const LDAP = require('ldapjs-client-sync');

const ldap = new LDAP();

ldap.connect()

连接服务器,该方法参数详见官方文档中ldap.createClient()方法的参数

如果连接成功,将返回客户端对象,所有同步方法都在该客户端对象中。

示例:

const LDAP = require('ldapjs-client-sync');

const ldap = new LDAP(); // 创建ldap实例

// 连接服务器,获取客户端对象
const client = await ldap.connect({
  url: ['ldap://127.0.0.1:1389', 'ldap://127.0.0.2:1389']
});

client.bindSync()

bind的同步方法,参数详见官方文档-bind()方法

示例:

const LDAP = require('ldapjs-client-sync');

const ldap = new LDAP(); // 创建ldap实例

// 连接服务器,获取客户端对象
const client = await ldap.connect({
  url: ['ldap://127.0.0.1:1389', 'ldap://127.0.0.2:1389']
});

// 绑定客户端到指定DN
await client.bindSync('cn=admin,dc=example,dc=org', 'my_password');

client.searchSync()

search的同步方法,参数详见官方文档-search()方法

示例:

const LDAP = require('ldapjs-client-sync');

const ldap = new LDAP(); // 创建ldap实例

// 连接服务器,获取客户端对象
const client = await ldap.connect({
  url: ['ldap://127.0.0.1:1389', 'ldap://127.0.0.2:1389']
});

// 绑定客户端到指定DN
await client.bindSync('cn=admin,dc=example,dc=org', 'my_password');

// 搜索指定DN的数据
const result = await client.searchSync('o=my_organization,dc=example,dc=org');

console.log(result.objects[0]);

client.addSync()

add的同步方法,参数详见官方文档-add()方法

client.delSync()

del的同步方法,参数详见官方文档-del()方法

client.modifySync()

modify的同步方法,参数详见官方文档-modify()方法

client.modifyDNSync()

modifyDN的同步方法,参数详见官方文档-modifyDN()方法

client.starttlsSync()

starttls的同步方法,参数详见官方文档-starttls()方法

client.unbindSync()

unbind的同步方法,参数详见官方文档-unbind()方法

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.