Socket
Socket
Sign inDemoInstall

ldap-schema-ts-generator

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap-schema-ts-generator

Typescript typedef and meta-data generator for LDAP Schema. It can be useful to interact from schema-aware/type-safe LDAP Client with LDAP servers like active directory.


Version published
Weekly downloads
12
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

Typescript typedef and meta-data generator for LDAP Schema

It can be useful to interact from schema-aware/type-safe LDAP Client with LDAP servers like active directory.

How to use

npm i ldap-schema-ts-generator
import {
  getSchemaAttributes,
  getSchemaClasses,
  generateInterfaceFiles,
} from "ldap-schema-ts-generator";

const options = {
  user: "**********",
  pass: "************",
  ldapServerUrl: "ldap://domain.com",
};

const schemaDn = await getSchemaNamingContext({ options });

const objectAttributes = await getSchemaAttributes({ schemaDn, options });

const objectClasses = await getSchemaClasses({ schemaDn, options });

await generateInterfaceFiles({ objectAttributes, objectClasses });
}

Options:

options?: {
    /** default generated folder of root directory of you project */
    outputFolder?: string;
    /** use prettier to format generated files. default true */
    usePrettier?: boolean;
    /** create index file for output folder. default true */
    indexFile: boolean;
  };

API

use api website for more details

Result

creates typescript interface for each LDAP class that exist in schema

Sample Generated File:

import { Top } from "./Top";
import { MsExchBaseClass } from "./MsExchBaseClass";

/**  - object class: container
 *  - child of class: top
 *  - dn: CN=Container,CN=Schema,CN=Configuration,DC=ki,DC=local
 */

export interface Container extends Top, MsExchBaseClass {
  /**  - attributeSyntax: 2.5.5.12
   *   - attributeID: 2.5.4.3
   *   - adminDisplayName: Common-Name
   *   - adminDescription: Common-Name
   *   - dn: CN=Common-Name,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  readonly cn: string;

  /**  - attributeSyntax: 2.5.5.12
   *   - attributeID: 1.2.840.113556.1.2.508
   *   - adminDisplayName: ms-Exch-X500-RDN
   *   - adminDescription: ms-Exch-X500-RDN
   *   - dn: CN=ms-Exch-X500-RDN,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  x500RDN?: string;

  /**  - attributeSyntax: 2.5.5.4
   *   - attributeID: 1.2.840.113556.1.4.7000.102.65
   *   - adminDisplayName: ms-Exch-Template-RDNs
   *   - adminDescription: ms-Exch-Template-RDNs
   *   - dn: CN=ms-Exch-Template-RDNs,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  msExchTemplateRDNs?: string[];

  /**  - attributeSyntax: 2.5.5.1
   *   - attributeID: 1.2.840.113556.1.4.7000.102.50004
   *   - adminDisplayName: ms-Exch-Policy-List
   *   - adminDescription: ms-Exch-Policy-List
   *   - dn: CN=ms-Exch-Policy-List,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  msExchPolicyList?: object[];

  /**  - attributeSyntax: 2.5.5.9
   *   - attributeID: 1.2.840.113556.1.2.296
   *   - adminDisplayName: ms-Exch-Container-Info
   *   - adminDescription: ms-Exch-Container-Info
   *   - dn: CN=ms-Exch-Container-Info,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  containerInfo?: number;

  /**  - attributeSyntax: 2.5.5.1
   *   - attributeID: 1.2.840.113556.1.4.7000.102.1027
   *   - adminDisplayName: ms-Exch-Export-Containers-BL
   *   - adminDescription: ms-Exch-Export-Containers-BL
   *   - dn: CN=ms-Exch-Export-Containers-BL,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  msExchExportContainersBL?: object;

  /**  - attributeSyntax: 2.5.5.1
   *   - attributeID: 1.2.840.113556.1.4.1840
   *   - adminDisplayName: ms-DS-Object-Reference
   *   - adminDescription: A link to the object that uses the data stored in the object that contains this attribute.
   *   - dn: CN=ms-DS-Object-Reference,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  "msDS-ObjectReference"?: object[];

  /**  - attributeSyntax: 2.5.5.9
   *   - attributeID: 1.2.840.113556.1.2.471
   *   - adminDisplayName: Schema-Version
   *   - adminDescription: Schema-Version
   *   - dn: CN=Schema-Version,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  readonly schemaVersion?: number[];

  /**  - attributeSyntax: 2.5.5.1
   *   - attributeID: 1.2.840.113556.1.4.213
   *   - adminDisplayName: Default-Class-Store
   *   - adminDescription: Default-Class-Store
   *   - dn: CN=Default-Class-Store,CN=Schema,CN=Configuration,DC=ki,DC=local
   */
  readonly defaultClassStore?: object[];
}

TODO:

  • handle relations (forwardLink/BackLink) via linkID field
  • change relation DN fields type from object to string
  • generate ldap controls supported by server from RootDSE
  • generate ldap capabilities supported by server from RootDSE
  • generate ldap extensions supported by server from RootDSE
  • generate ldap policies supported by server from RootDSE
  • generate Base DNs from RootDSE (List of DNs of all the naming contexts and application partitions maintained by the DC)
  • generate naming contexts fields from RootDSE (e.g. defaultNamingContext, configurationNamingContext, schemaNamingContext, rootNamingContext)
  • Active Directory create a functionality to fetch all meta data about server ref
  • add option to customize generated file names with prefix/postfix (now it 's using Pascal case of ldap display name as interface and file name)

Know Issues

  • when extends to another interface sometimes a field is optional but in other interface is not so typescript gives compatibility warning which prevent generated code to be executed with typescript complier. to fix the problem an extra comment // @ts-ignore added in top of all generated interfaces

Credit

Keywords

FAQs

Package last updated on 13 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc