ber_put_boolean - Linux


Overview

The ber_put_boolean command in LDAP is used to write a boolean value into an LDAP PDU.

Syntax

int ber_put_boolean(ber_element *ber, int boolean)

Where:

  • ber is a pointer to an existing BER element.
  • boolean is the boolean value (0 or 1) to be written.

Options/Flags

None.

Examples

The following program writes a boolean value to an LDAP PDU:

#include <stdio.h>
#include <stdlib.h>
#include <ldap.h>

int main(void)
{
  ber_element *ber;
  int boolean = 1;

  /* Initialize the BER element. */
  ber = ber_alloc_t(LBER_TYPE_BOOLEAN);
  if (ber == NULL)
  {
    perror("ber_alloc_t");
    return EXIT_FAILURE;
  }

  /* Write the boolean value to the BER element. */
  if (ber_put_boolean(ber, boolean) == -1)
  {
    perror("ber_put_boolean");
    ber_free(ber);
    return EXIT_FAILURE;
  }

  /* Print the BER element. */
  printf("BER element: %s\n", ber_dump(ber, 0));

  /* Free the BER element. */
  ber_free(ber);

  return EXIT_SUCCESS;
}

Common Issues

None.

Integration

The ber_put_boolean command can be used with other LDAP commands to create and modify LDAP PDUs. For example, it can be used with the ldap_add command to add a boolean value to an LDAP entry.

Related Commands