Skip to content

Instantly share code, notes, and snippets.

@davistran86
Last active December 2, 2020 03:54
Show Gist options
  • Save davistran86/417c2e19bb6f2dae26c80d17f38e1013 to your computer and use it in GitHub Desktop.
Save davistran86/417c2e19bb6f2dae26c80d17f38e1013 to your computer and use it in GitHub Desktop.

Delete non-leaf user in Active Directory

Extended control

https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ldap/extended-controls

Example

const { Client } = require("ldapts");
const { Control } = require("ldapts/controls");

const url = "ldap://....";
const bindDN = "CN=ICT service,OU=app-users,DC=...,DC=...";
const password = "....";

const client = new Client({
  url,
});

const main = async () => {
  try {
    await client.bind(bindDN, password);

    const res = await client.del(
      "CN=Super Man,OU=DISABLE users & computers,DC=...,DC=...",
      new Control("1.2.840.113556.1.4.805")
    );
    console.log(res);
  } catch (ex) {
    throw ex;
  } finally {
    await client.unbind();
  }
};

main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment