Ldap Active Directory Schema Typescript Generator
How to use
npm i ldap-schema-ts-generator
import {
getSchemaAttributes,
getSchemaClasses,
generateInterfaceFiles,
} from "ldap-schema-ts-generator";
async function main() {
const schemaDn = "CN=Schema,CN=Configuration,DC=domain,DC=com";
const options = {
user: "**********",
pass: "************",
ldapServerUrl: "ldap://domain.com",
};
const objectAttributes = await getSchemaAttributes({ schemaDn, options });
const objectClasses = await getSchemaClasses({ schemaDn, options });
await generateInterfaceFiles({ objectAttributes, objectClasses });
}
main().catch((err) => {
console.log(err);
});
Options:
options?: {
outputFolder?: string;
usePrettier?: boolean;
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";
export interface Container extends Top, MsExchBaseClass {
readonly cn: string;
x500RDN?: string;
msExchTemplateRDNs?: string[];
msExchPolicyList?: object[];
containerInfo?: number;
msExchExportContainersBL?: object;
"msDS-ObjectReference"?: object[];
readonly schemaVersion?: number[];
readonly defaultClassStore?: object[];
}
TODO:
Know Issues
- when extends to another interface sometimes a field is optional but in other interface is not so typescript gives compatibility warning
Credit