Guest User

Untitled

a guest
Apr 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ldap.h>
  4.  
  5. int main(int argc, char **argv) {
  6. if (argc < 2) {
  7. printf("Usage!\n");
  8. exit(1);
  9. }
  10.  
  11. LDAPDN dn = NULL;
  12. if (LDAP_SUCCESS != ldap_str2dn(argv[1], &dn, LDAP_DN_FORMAT_LDAPV3)) {
  13. printf("Failed to parse DN\n");
  14. exit(1);
  15. }
  16. for (int i = 0; dn[i] != NULL; i++) {
  17. LDAPRDN rdn = dn[i];
  18. printf("RDN %d\n", i);
  19. for (int j = 0; rdn[j] != NULL; j++) {
  20. LDAPAVA *ava = rdn[j];
  21. printf(" AVA %d %s=%s\n", j, ava->la_attr.bv_val, ava->la_value.bv_val);
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment