Documentationcurrent version
Help us improve the docs by fixing typos and proposing enhancements.


Action "ldap.delete"

Insert or modify an entry inside an OpenLDAP server.


const {$status} = await nikita.ldap.delete({
  uri: 'ldap://openldap.server/',
  binddn: 'cn=admin,cn=config',
  passwd: 'password',
  dn: 'cn=group1,ou=groups,dc=company,dc=com'
console.log(`Entry deleted: ${$status}`)

Schema definitions

definitions =
    type: 'object'
        type: 'array'
        items: type: 'string'
        description: '''
        One or multiple DN to remove.
        type: 'string'
        description: '''
        Distinguish name storing the "olcAccess" property, using the database
        address (eg: "olcDatabase={2}bdb,cn=config").
      # General LDAP connection information
        type: 'string'
        description: '''
        Distinguished Name to bind to the LDAP directory.
        type: 'string'
        description: '''
        Password for simple authentication.
        type: 'string'
        description: '''
        LDAP Uniform Resource Identifier(s), "ldapi:///" if true, default to
        false in which case it will use your openldap client environment
    required: ['dn']


handler = ({config}) ->
  # Auth related config
  binddn = if config.binddn then "-D #{config.binddn}" else ''
  passwd = if config.passwd then "-w #{config.passwd}" else ''
  config.uri = 'ldapi:///' if config.uri is true
  uri = if config.uri then "-H #{config.uri}" else '' # URI is obtained from local openldap conf unless provided
  # Add related config
  config.dn = [config.dn] unless Array.isArray config.dn
  dn = (dn) -> "'#{dn}'").join(' ')
  # ldapdelete -D cn=Manager,dc=ryba -w test -H ldaps://master3.ryba:636 'cn=nikita,ou=users,dc=ryba'
  await @execute
    # Check that the entry exists
    $if_execute: "ldapsearch #{binddn} #{passwd} #{uri} -b #{dn} -s base"
    command: "ldapdelete #{binddn} #{passwd} #{uri} #{dn}"
    # code: [0, 68]
  # modified = stderr.match(/Already exists/g)?.length isnt stdout.match(/adding new entry/g).length
  # added = modified # For now, we dont modify
  # callback err, modified, added


module.exports =
  handler: handler
    global: 'ldap'
    definitions: definitions
Edit on GitHub

Nikita is an open source project hosted on GitHub and developed by Adaltas.