8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libldap5 / sources / ldap / common / url.c
blobfc0e1460f839c9c7e9a25325600839471b3d1db9
1 /*
2 * Copyright 2001-2003 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 #pragma ident "%Z%%M% %I% %E% SMI"
9 /*
10 * The contents of this file are subject to the Netscape Public
11 * License Version 1.1 (the "License"); you may not use this file
12 * except in compliance with the License. You may obtain a copy of
13 * the License at http://www.mozilla.org/NPL/
15 * Software distributed under the License is distributed on an "AS
16 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 * implied. See the License for the specific language governing
18 * rights and limitations under the License.
20 * The Original Code is Mozilla Communicator client code, released
21 * March 31, 1998.
23 * The Initial Developer of the Original Code is Netscape
24 * Communications Corporation. Portions created by Netscape are
25 * Copyright (C) 1998-1999 Netscape Communications Corporation. All
26 * Rights Reserved.
28 * Contributor(s):
31 * Copyright (c) 1996 Regents of the University of Michigan.
32 * All rights reserved.
35 /* LIBLDAP url.c -- LDAP URL related routines
37 * LDAP URLs look like this:
38 * l d a p : / / hostport / dn [ ? attributes [ ? scope [ ? filter ] ] ]
40 * where:
41 * attributes is a comma separated list
42 * scope is one of these three strings: base one sub (default=base)
43 * filter is an string-represented filter as in RFC 1558
45 * e.g., ldap://ldap.itd.umich.edu/c=US?o,description?one?o=umich
47 * We also tolerate URLs that look like: <ldapurl> and <URL:ldapurl>
50 #if 0
51 #ifndef lint
52 static char copyright[] = "@(#) Copyright (c) 1996 Regents of the University of Michigan.\nAll rights reserved.\n";
53 #endif
54 #endif
56 #include "ldap-int.h"
59 static int skip_url_prefix( const char **urlp, int *enclosedp, int *securep );
62 int
63 LDAP_CALL
64 ldap_is_ldap_url( const char *url )
66 int enclosed, secure;
68 return( url != NULL
69 && skip_url_prefix( &url, &enclosed, &secure ));
73 static int
74 skip_url_prefix( const char **urlp, int *enclosedp, int *securep )
77 * return non-zero if this looks like a LDAP URL; zero if not
78 * if non-zero returned, *urlp will be moved past "ldap://" part of URL
79 * The data that *urlp points to is not changed by this function.
81 if ( *urlp == NULL ) {
82 return( 0 );
85 /* skip leading '<' (if any) */
86 if ( **urlp == '<' ) {
87 *enclosedp = 1;
88 ++*urlp;
89 } else {
90 *enclosedp = 0;
93 /* skip leading "URL:" (if any) */
94 if ( strlen( *urlp ) >= LDAP_URL_URLCOLON_LEN && strncasecmp(
95 *urlp, LDAP_URL_URLCOLON, LDAP_URL_URLCOLON_LEN ) == 0 ) {
96 *urlp += LDAP_URL_URLCOLON_LEN;
99 /* check for an "ldap://" prefix */
100 if ( strlen( *urlp ) >= LDAP_URL_PREFIX_LEN && strncasecmp( *urlp,
101 LDAP_URL_PREFIX, LDAP_URL_PREFIX_LEN ) == 0 ) {
102 /* skip over URL prefix and return success */
103 *urlp += LDAP_URL_PREFIX_LEN;
104 *securep = 0;
105 return( 1 );
108 /* check for an "ldaps://" prefix */
109 if ( strlen( *urlp ) >= LDAPS_URL_PREFIX_LEN && strncasecmp( *urlp,
110 LDAPS_URL_PREFIX, LDAPS_URL_PREFIX_LEN ) == 0 ) {
111 /* skip over URL prefix and return success */
112 *urlp += LDAPS_URL_PREFIX_LEN;
113 *securep = 1;
114 return( 1 );
117 return( 0 ); /* not an LDAP URL */
122 LDAP_CALL
123 ldap_url_parse( const char *url, LDAPURLDesc **ludpp )
126 * Pick apart the pieces of an LDAP URL.
128 int rc;
130 if (( rc = nsldapi_url_parse( url, ludpp, 1 )) == 0 ) {
131 if ( (*ludpp)->lud_scope == -1 ) {
132 (*ludpp)->lud_scope = LDAP_SCOPE_BASE;
134 if ( (*ludpp)->lud_filter == NULL ) {
135 (*ludpp)->lud_filter = "(objectclass=*)";
137 if ( *((*ludpp)->lud_dn) == '\0' ) {
138 (*ludpp)->lud_dn = NULL;
142 return( rc );
145 /* same as ldap_url_parse(), but dn is not require */
147 LDAP_CALL
148 ldap_url_parse_nodn(const char *url, LDAPURLDesc **ludpp)
151 * Pick apart the pieces of an LDAP URL.
153 int rc;
155 if ((rc = nsldapi_url_parse(url, ludpp, 0)) == 0) {
156 if ((*ludpp)->lud_scope == -1) {
157 (*ludpp)->lud_scope = LDAP_SCOPE_BASE;
159 if ((*ludpp)->lud_filter == NULL) {
160 (*ludpp)->lud_filter = "(objectclass=*)";
162 if ((*ludpp)->lud_dn && *((*ludpp)->lud_dn) == '\0') {
163 (*ludpp)->lud_dn = NULL;
167 return (rc);
172 * like ldap_url_parse() with a few exceptions:
173 * 1) if dn_required is zero, a missing DN does not generate an error
174 * (we just leave the lud_dn field NULL)
175 * 2) no defaults are set for lud_scope and lud_filter (they are set to -1
176 * and NULL respectively if no SCOPE or FILTER are present in the URL).
177 * 3) when there is a zero-length DN in a URL we do not set lud_dn to NULL.
178 * 4) if an LDAPv3 URL extensions are included,
181 nsldapi_url_parse( const char *url, LDAPURLDesc **ludpp, int dn_required )
184 LDAPURLDesc *ludp;
185 char *urlcopy, *attrs, *scope, *extensions = NULL, *p, *q;
186 int enclosed, secure, i, nattrs, at_start;
188 LDAPDebug( LDAP_DEBUG_TRACE, "nsldapi_url_parse(%s)\n", url, 0, 0 );
190 if ( url == NULL || ludpp == NULL ) {
191 return( LDAP_URL_ERR_PARAM );
194 *ludpp = NULL; /* pessimistic */
196 if ( !skip_url_prefix( &url, &enclosed, &secure )) {
197 return( LDAP_URL_ERR_NOTLDAP );
200 /* allocate return struct */
201 if (( ludp = (LDAPURLDesc *)NSLDAPI_CALLOC( 1, sizeof( LDAPURLDesc )))
202 == NULLLDAPURLDESC ) {
203 return( LDAP_URL_ERR_MEM );
206 if ( secure ) {
207 ludp->lud_options |= LDAP_URL_OPT_SECURE;
210 /* make working copy of the remainder of the URL */
211 if (( urlcopy = nsldapi_strdup( url )) == NULL ) {
212 ldap_free_urldesc( ludp );
213 return( LDAP_URL_ERR_MEM );
216 if ( enclosed && *((p = urlcopy + strlen( urlcopy ) - 1)) == '>' ) {
217 *p = '\0';
220 /* initialize scope and filter */
221 ludp->lud_scope = -1;
222 ludp->lud_filter = NULL;
224 /* lud_string is the only malloc'd string space we use */
225 ludp->lud_string = urlcopy;
227 /* scan forward for '/' that marks end of hostport and begin. of dn */
228 if (( ludp->lud_dn = strchr( urlcopy, '/' )) == NULL ) {
229 if ( dn_required ) {
230 ldap_free_urldesc( ludp );
231 return( LDAP_URL_ERR_NODN );
233 } else {
234 /* terminate hostport; point to start of dn */
235 *ludp->lud_dn++ = '\0';
239 if ( *urlcopy == '\0' ) {
240 ludp->lud_host = NULL;
241 } else {
242 ludp->lud_host = urlcopy;
243 nsldapi_hex_unescape( ludp->lud_host );
246 * Locate and strip off optional port number (:#) in host
247 * portion of URL.
249 * If more than one space-separated host is listed, we only
250 * look for a port number within the right-most one since
251 * ldap_init() will handle host parameters that look like
252 * host:port anyway.
254 if (( p = strrchr( ludp->lud_host, ' ' )) == NULL ) {
255 p = ludp->lud_host;
256 } else {
257 ++p;
259 if ( *p == '[' && ( q = strchr( p, ']' )) != NULL ) {
260 /* square brackets present -- skip past them */
261 p = q++;
263 if (( p = strchr( p, ':' )) != NULL ) {
264 *p++ = '\0';
265 ludp->lud_port = atoi( p );
266 if ( *ludp->lud_host == '\0' ) {
268 * no hostname and a port: invalid hostcode
269 * according to RFC 1738
271 ldap_free_urldesc(ludp);
272 return (LDAP_URL_ERR_HOSTPORT);
277 /* scan for '?' that marks end of dn and beginning of attributes */
278 attrs = NULL;
279 if ( ludp->lud_dn != NULL &&
280 ( attrs = strchr( ludp->lud_dn, '?' )) != NULL ) {
281 /* terminate dn; point to start of attrs. */
282 *attrs++ = '\0';
284 /* scan for '?' that marks end of attrs and begin. of scope */
285 if (( p = strchr( attrs, '?' )) != NULL ) {
287 * terminate attrs; point to start of scope and scan for
288 * '?' that marks end of scope and begin. of filter
290 *p++ = '\0';
291 scope = p;
293 if (( p = strchr( scope, '?' )) != NULL ) {
294 /* terminate scope; point to start of filter */
295 *p++ = '\0';
296 if ( *p != '\0' ) {
297 ludp->lud_filter = p;
299 * scan for the '?' that marks the end
300 * of the filter and the start of any
301 * extensions
303 if (( p = strchr( ludp->lud_filter, '?' ))
304 != NULL ) {
305 *p++ = '\0'; /* term. filter */
306 extensions = p;
308 if ( *ludp->lud_filter == '\0' ) {
309 ludp->lud_filter = NULL;
310 } else {
311 nsldapi_hex_unescape( ludp->lud_filter );
317 if ( strcasecmp( scope, "one" ) == 0 ) {
318 ludp->lud_scope = LDAP_SCOPE_ONELEVEL;
319 } else if ( strcasecmp( scope, "base" ) == 0 ) {
320 ludp->lud_scope = LDAP_SCOPE_BASE;
321 } else if ( strcasecmp( scope, "sub" ) == 0 ) {
322 ludp->lud_scope = LDAP_SCOPE_SUBTREE;
323 } else if ( *scope != '\0' ) {
324 ldap_free_urldesc( ludp );
325 return( LDAP_URL_ERR_BADSCOPE );
330 if ( ludp->lud_dn != NULL ) {
331 nsldapi_hex_unescape( ludp->lud_dn );
335 * if attrs list was included, turn it into a null-terminated array
337 if ( attrs != NULL && *attrs != '\0' ) {
338 nsldapi_hex_unescape( attrs );
339 for ( nattrs = 1, p = attrs; *p != '\0'; ++p ) {
340 if ( *p == ',' ) {
341 ++nattrs;
345 if (( ludp->lud_attrs = (char **)NSLDAPI_CALLOC( nattrs + 1,
346 sizeof( char * ))) == NULL ) {
347 ldap_free_urldesc( ludp );
348 return( LDAP_URL_ERR_MEM );
351 for ( i = 0, p = attrs; i < nattrs; ++i ) {
352 ludp->lud_attrs[ i ] = p;
353 if (( p = strchr( p, ',' )) != NULL ) {
354 *p++ ='\0';
356 nsldapi_hex_unescape( ludp->lud_attrs[ i ] );
360 /* if extensions list was included, check for critical ones */
361 if ( extensions != NULL && *extensions != '\0' ) {
362 /* Note: at present, we do not recognize ANY extensions */
363 at_start = 1;
364 for ( p = extensions; *p != '\0'; ++p ) {
365 if ( at_start ) {
366 if ( *p == '!' ) { /* critical extension */
367 ldap_free_urldesc( ludp );
368 /* this is what iplanet did *
369 return( LDAP_URL_UNRECOGNIZED_CRITICAL_EXTENSION );
370 * and this is what we do */
371 return( LDAP_URL_ERR_PARAM );
373 at_start = 0;
374 } else if ( *p == ',' ) {
375 at_start = 1;
381 *ludpp = ludp;
383 return( 0 );
387 void
388 LDAP_CALL
389 ldap_free_urldesc( LDAPURLDesc *ludp )
391 if ( ludp != NULLLDAPURLDESC ) {
392 if ( ludp->lud_string != NULL ) {
393 NSLDAPI_FREE( ludp->lud_string );
395 if ( ludp->lud_attrs != NULL ) {
396 NSLDAPI_FREE( ludp->lud_attrs );
398 NSLDAPI_FREE( ludp );
404 LDAP_CALL
405 ldap_url_search( LDAP *ld, const char *url, int attrsonly )
407 int err, msgid;
408 LDAPURLDesc *ludp;
409 BerElement *ber;
410 LDAPServer *srv;
411 char *host;
413 if ( !NSLDAPI_VALID_LDAP_POINTER( ld )) {
414 return( -1 ); /* punt */
417 if ( ldap_url_parse( url, &ludp ) != 0 ) {
418 LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL );
419 return( -1 );
422 LDAP_MUTEX_LOCK( ld, LDAP_MSGID_LOCK );
423 msgid = ++ld->ld_msgid;
424 LDAP_MUTEX_UNLOCK( ld, LDAP_MSGID_LOCK );
426 if ( nsldapi_build_search_req( ld, ludp->lud_dn, ludp->lud_scope,
427 ludp->lud_filter, ludp->lud_attrs, attrsonly, NULL, NULL,
428 -1, -1, msgid, &ber ) != LDAP_SUCCESS ) {
429 return( -1 );
432 err = 0;
434 if ( ludp->lud_host == NULL ) {
435 host = ld->ld_defhost;
436 } else {
437 host = ludp->lud_host;
440 if (( srv = (LDAPServer *)NSLDAPI_CALLOC( 1, sizeof( LDAPServer )))
441 == NULL || ( host != NULL &&
442 ( srv->lsrv_host = nsldapi_strdup( host )) == NULL )) {
443 if ( srv != NULL ) {
444 NSLDAPI_FREE( srv );
446 LDAP_SET_LDERRNO( ld, LDAP_NO_MEMORY, NULL, NULL );
447 err = -1;
448 } else {
449 if ( ludp->lud_port != 0 ) {
450 /* URL includes a port - use it */
451 srv->lsrv_port = ludp->lud_port;
452 } else if ( ludp->lud_host == NULL ) {
453 /* URL has no port or host - use port from ld */
454 srv->lsrv_port = ld->ld_defport;
455 } else if (( ludp->lud_options & LDAP_URL_OPT_SECURE ) == 0 ) {
456 /* ldap URL has a host but no port - use std. port */
457 srv->lsrv_port = LDAP_PORT;
458 } else {
459 /* ldaps URL has a host but no port - use std. port */
460 srv->lsrv_port = LDAPS_PORT;
464 if (( ludp->lud_options & LDAP_URL_OPT_SECURE ) != 0 ) {
465 srv->lsrv_options |= LDAP_SRV_OPT_SECURE;
468 if ( err != 0 ) {
469 ber_free( ber, 1 );
470 } else {
471 err = nsldapi_send_server_request( ld, ber, msgid, NULL, srv,
472 NULL, NULL, 1 );
475 ldap_free_urldesc( ludp );
476 return( err );
481 LDAP_CALL
482 ldap_url_search_st( LDAP *ld, const char *url, int attrsonly,
483 struct timeval *timeout, LDAPMessage **res )
485 int msgid;
488 * It is an error to pass in a zero'd timeval.
490 if ( timeout != NULL && timeout->tv_sec == 0 &&
491 timeout->tv_usec == 0 ) {
492 if ( ld != NULL ) {
493 LDAP_SET_LDERRNO( ld, LDAP_PARAM_ERROR, NULL, NULL );
495 if ( res != NULL ) {
496 *res = NULL;
498 return( LDAP_PARAM_ERROR );
501 if (( msgid = ldap_url_search( ld, url, attrsonly )) == -1 ) {
502 return( LDAP_GET_LDERRNO( ld, NULL, NULL ) );
505 if ( ldap_result( ld, msgid, 1, timeout, res ) == -1 ) {
506 return( LDAP_GET_LDERRNO( ld, NULL, NULL ) );
509 if ( LDAP_GET_LDERRNO( ld, NULL, NULL ) == LDAP_TIMEOUT ) {
510 (void) ldap_abandon( ld, msgid );
511 LDAP_SET_LDERRNO( ld, LDAP_TIMEOUT, NULL, NULL );
512 return( LDAP_TIMEOUT );
515 return( ldap_result2error( ld, *res, 0 ));
520 LDAP_CALL
521 ldap_url_search_s( LDAP *ld, const char *url, int attrsonly, LDAPMessage **res )
523 int msgid;
525 if (( msgid = ldap_url_search( ld, url, attrsonly )) == -1 ) {
526 return( LDAP_GET_LDERRNO( ld, NULL, NULL ) );
529 if ( ldap_result( ld, msgid, 1, (struct timeval *)NULL, res ) == -1 ) {
530 return( LDAP_GET_LDERRNO( ld, NULL, NULL ) );
533 return( ldap_result2error( ld, *res, 0 ));
536 #ifdef _SOLARIS_SDK
538 * Locate the LDAP URL associated with a DNS domain name.
540 * The supplied DNS domain name is converted into a distinguished
541 * name. The directory entry specified by that distinguished name
542 * is searched for a labeledURI attribute. If successful then the
543 * LDAP URL is returned. If unsuccessful then that entry's parent
544 * is searched and so on until the target distinguished name is
545 * reduced to only two nameparts.
547 * For example, if 'ny.eng.wiz.com' is the DNS domain then the
548 * following entries are searched until one succeeds:
549 * dc=ny,dc=eng,dc=wiz,dc=com
550 * dc=eng,dc=wiz,dc=com
551 * dc=wiz,dc=com
553 * If dns_name is NULL then the environment variable LOCALDOMAIN is used.
554 * If attrs is not NULL then it is appended to the URL's attribute list.
555 * If scope is not NULL then it overrides the URL's scope.
556 * If filter is not NULL then it is merged with the URL's filter.
558 * If an error is encountered then zero is returned, otherwise a string
559 * URL is returned. The caller should free the returned string if it is
560 * non-zero.
563 char *
564 ldap_dns_to_url(
565 LDAP *ld,
566 char *dns_name,
567 char *attrs,
568 char *scope,
569 char *filter
572 char *dn;
573 char *url = 0;
574 char *url2 = 0;
575 LDAPURLDesc *urldesc;
576 char *cp;
577 char *cp2;
578 size_t attrs_len = 0;
579 size_t scope_len = 0;
580 size_t filter_len = 0;
581 int nameparts;
582 int no_attrs = 0;
583 int no_scope = 0;
585 if (dns_name == 0) {
586 dns_name = (char *)getenv("LOCALDOMAIN");
589 if ((ld == NULL) || ((dn = ldap_dns_to_dn(dns_name, &nameparts)) ==
590 NULL))
591 return (0);
593 if ((url = ldap_dn_to_url(ld, dn, nameparts)) == NULL) {
594 free(dn);
595 return (0);
597 free(dn);
599 /* merge filter and/or scope and/or attributes with URL */
600 if (attrs || scope || filter) {
602 if (attrs)
603 attrs_len = strlen(attrs) + 2; /* for comma and NULL */
605 if (scope)
606 scope_len = strlen(scope) + 1; /* for NULL */
608 if (filter)
609 filter_len = strlen(filter) + 4;
610 /* for ampersand, parentheses and NULL */
612 if (ldap_is_ldap_url(url)) {
614 if ((url2 = (char *)malloc(attrs_len + scope_len +
615 filter_len + strlen(url) + 1)) == NULL) {
616 return (0);
618 cp = url;
619 cp2 = url2;
621 /* copy URL scheme, hostname, port number and DN */
622 while (*cp && (*cp != '?')) {
623 *cp2++ = *cp++;
626 /* handle URL attributes */
628 if (*cp == '?') { /* test first '?' */
629 *cp2++ = *cp++; /* copy first '?' */
631 if (*cp == '?') { /* test second '?' */
633 /* insert supplied attributes */
634 if (attrs) {
635 while (*attrs) {
636 *cp2++ = *attrs++;
638 } else {
639 no_attrs = 1;
642 } else {
644 /* copy URL attributes */
645 while (*cp && (*cp != '?')) {
646 *cp2++ = *cp++;
649 /* append supplied attributes */
650 if (attrs) {
651 *cp2++ = ',';
652 while (*attrs) {
653 *cp2++ = *attrs++;
658 } else {
659 /* append supplied attributes */
660 if (attrs) {
661 *cp2++ = '?';
662 while (*attrs) {
663 *cp2++ = *attrs++;
665 } else {
666 no_attrs = 1;
670 /* handle URL scope */
672 if (*cp == '?') { /* test second '?' */
673 *cp2++ = *cp++; /* copy second '?' */
675 if (*cp == '?') { /* test third '?' */
677 /* insert supplied scope */
678 if (scope) {
679 while (*scope) {
680 *cp2++ = *scope++;
682 } else {
683 no_scope = 1;
686 } else {
688 if (scope) {
689 /* skip over URL scope */
690 while (*cp && (*cp != '?')) {
691 *cp++;
693 /* insert supplied scope */
694 while (*scope) {
695 *cp2++ = *scope++;
697 } else {
699 /* copy URL scope */
700 while (*cp && (*cp != '?')) {
701 *cp2++ = *cp++;
706 } else {
707 /* append supplied scope */
708 if (scope) {
709 if (no_attrs) {
710 *cp2++ = '?';
712 *cp2++ = '?';
713 while (*scope) {
714 *cp2++ = *scope++;
716 } else {
717 no_scope = 1;
721 /* handle URL filter */
723 if (*cp == '?') { /* test third '?' */
724 *cp2++ = *cp++; /* copy third '?' */
726 if (filter) {
728 /* merge URL and supplied filters */
730 *cp2++ = '(';
731 *cp2++ = '&';
732 /* copy URL filter */
733 while (*cp) {
734 *cp2++ = *cp++;
736 /* append supplied filter */
737 while (*filter) {
738 *cp2++ = *filter++;
740 *cp2++ = ')';
741 } else {
743 /* copy URL filter */
744 while (*cp) {
745 *cp2++ = *cp++;
749 } else {
750 /* append supplied filter */
751 if (filter) {
752 if (no_scope) {
753 if (no_attrs) {
754 *cp2++ = '?';
756 *cp2++ = '?';
758 *cp2++ = '?';
759 while (*filter) {
760 *cp2++ = *filter++;
765 *cp2++ = '\0';
766 free (url);
767 url = url2;
769 } else {
770 return (0); /* not an LDAP URL */
773 return (url);
777 * Locate the LDAP URL associated with a distinguished name.
779 * The number of nameparts in the supplied distinguished name must be
780 * provided. The specified directory entry is searched for a labeledURI
781 * attribute. If successful then the LDAP URL is returned. If unsuccessful
782 * then that entry's parent is searched and so on until the target
783 * distinguished name is reduced to only two nameparts.
785 * For example, if 'l=ny,ou=eng,o=wiz,c=us' is the distinguished name
786 * then the following entries are searched until one succeeds:
787 * l=ny,ou=eng,o=wiz,c=us
788 * ou=eng,o=wiz,c=us
789 * o=wiz,c=us
791 * If an error is encountered then zero is returned, otherwise a string
792 * URL is returned. The caller should free the returned string if it is
793 * non-zero.
796 char *
797 ldap_dn_to_url(
798 LDAP *ld,
799 char *dn,
800 int nameparts
803 char *next_dn = dn;
804 char *url = 0;
805 char *attrs[2] = {"labeledURI", 0};
806 LDAPMessage *res, *e;
807 char **vals;
810 * Search for a URL in the named entry or its parent entry.
811 * Continue until only 2 nameparts remain.
813 while (dn && (nameparts > 1) && (! url)) {
815 /* search for the labeledURI attribute */
816 if (ldap_search_s(ld, dn, LDAP_SCOPE_BASE,
817 "(objectClass=*)", attrs, 0, &res) == LDAP_SUCCESS) {
819 /* locate the first entry returned */
820 if ((e = ldap_first_entry(ld, res)) != NULL) {
822 /* locate the labeledURI attribute */
823 if ((vals =
824 ldap_get_values(ld, e, "labeledURI")) !=
825 NULL) {
827 /* copy the attribute value */
828 if ((url = strdup((char *)vals[0])) !=
829 NULL) {
830 ldap_value_free(vals);
834 /* free the search results */
835 if (res != NULL) {
836 ldap_msgfree(res);
840 if (! url) {
841 /* advance along the DN by one namepart */
842 if (next_dn = strchr(dn, ',')) {
843 next_dn++;
844 dn = next_dn;
845 nameparts--;
850 return (url);
853 #endif /* _SOLARIS_SDK */