aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/doc/references/libldap/ldap_search_ext.c
diff options
context:
space:
mode:
Diffstat (limited to 'doc/references/libldap/ldap_search_ext.c')
-rw-r--r--doc/references/libldap/ldap_search_ext.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/doc/references/libldap/ldap_search_ext.c b/doc/references/libldap/ldap_search_ext.c
index 613698f..6810c44 100644
--- a/doc/references/libldap/ldap_search_ext.c
+++ b/doc/references/libldap/ldap_search_ext.c
@@ -41,6 +41,8 @@
41 41
42#include <stdio.h> 42#include <stdio.h>
43#include <stdlib.h> 43#include <stdlib.h>
44
45#define LDAP_DEPRECATED 1
44#include <ldap.h> 46#include <ldap.h>
45 47
46int main(void); 48int main(void);
@@ -62,6 +64,7 @@ int main(void)
62 BerValue cred; 64 BerValue cred;
63 BerElement * ber; 65 BerElement * ber;
64 BerValue * servercredp; 66 BerValue * servercredp;
67 char ** rdns;
65 struct berval ** vals; 68 struct berval ** vals;
66 char * attrs[32]; 69 char * attrs[32];
67 70
@@ -181,7 +184,54 @@ int main(void)
181 msg = ldap_first_entry(ld, res); 184 msg = ldap_first_entry(ld, res);
182 while ((msg)) 185 while ((msg))
183 { 186 {
187 // retrieve DN
184 dn = ldap_get_dn(ld, msg); 188 dn = ldap_get_dn(ld, msg);
189
190 // prints DN in "User Friendly Naming" format
191 if ((str = ldap_dn2ufn(dn)) == NULL)
192 {
193 fprintf(stderr, "ldap_dn2ufn(): out of virtual memory\n");
194 ldap_unbind_ext_s(ld, NULL, NULL);
195 return(1);
196 };
197 printf("# UFN: %s\n", str);
198 ldap_memfree(str);
199
200 // prints DN using "DCE" style
201 if ((str = ldap_dn2dcedn(dn)) == NULL)
202 {
203 fprintf(stderr, "ldap_dn2dcedn(): out of virtual memory\n");
204 ldap_unbind_ext_s(ld, NULL, NULL);
205 return(1);
206 };
207 printf("# DCE: %s\n", str);
208 ldap_memfree(str);
209
210 // prints DN as "AD canonical name"
211 if ((str = ldap_dn2ad_canonical(dn)) == NULL)
212 {
213 fprintf(stderr, "ldap_dn2dcedn(): out of virtual memory\n");
214 ldap_unbind_ext_s(ld, NULL, NULL);
215 return(1);
216 };
217 printf("# ADC: %s\n", str);
218 ldap_memfree(str);
219
220 // prints RDNs
221 if ((rdns = ldap_explode_dn(dn, 0)) == NULL)
222 {
223 fprintf(stderr, "ldap_explode_dn(): out of virtual memory\n");
224 ldap_unbind_ext_s(ld, NULL, NULL);
225 return(1);
226 };
227 for(i = 0; ((rdns[i])); i++)
228 {
229 printf("# RDN %i: %s\n", i, rdns[i]);
230 };
231 ldap_value_free(rdns);
232
233
234 // prints and free DN
185 printf("dn: %s\n", dn); 235 printf("dn: %s\n", dn);
186 ldap_memfree(dn); 236 ldap_memfree(dn);
187 237