mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* initialized ldapjs-client typings * client is a Class, not a factory function * removed JSDOC, fixed linting * fix tsconfig and typescript version. lint should go green * removing unnecessary generic * unknown type is supported after TS 3.0 * enabling npm-naming and complying to it * exporting interface in commonjs style, and minor cleanup
45 lines
952 B
TypeScript
45 lines
952 B
TypeScript
import LdapJS = require('ldapjs-client');
|
|
|
|
const clientOptions: LdapJS.ClientOptions = {
|
|
url: 'ldap://anyserver:389',
|
|
};
|
|
|
|
const client = new LdapJS(clientOptions);
|
|
|
|
const dn = 'cn=foo, o=example';
|
|
|
|
interface LdapObject {
|
|
cn: string;
|
|
ou: string;
|
|
}
|
|
|
|
(async () => {
|
|
await client.add(dn, { cn: 'foo' });
|
|
|
|
await client.bind(dn, 'pazzvord');
|
|
await client.del(dn);
|
|
|
|
const change: LdapJS.Change = {
|
|
operation: 'add',
|
|
modification: {
|
|
pets: ['cat', 'dog'],
|
|
},
|
|
};
|
|
|
|
await client.modify(dn, change);
|
|
await client.modifyDN(dn, 'cn=baz, o=example');
|
|
|
|
const options: LdapJS.SearchOptions = {
|
|
filter: '(&(l=Seattle)(email=*@foo.com))',
|
|
scope: 'sub',
|
|
attributes: ['dn', 'sn', 'cn'],
|
|
};
|
|
|
|
const searchResult = await client.search(dn, options) as LdapObject[];
|
|
type resultType = typeof searchResult;
|
|
|
|
await client.unbind();
|
|
|
|
client.destroy();
|
|
})();
|