Up to Contents

Back to Using SSL

Parsing LDAP URLs

The routines in this section can be used for parsing urls of the ldap://host:port/ form. They are specific to the Innosoft implementation.


	  typedef struct ldap_url_desc {
	      char	*lud_host;
	      int	 lud_port;
	      char	*lud_dn;
	      char	**lud_attrs;
	      int	 lud_scope;
	      char	*lud_filter;
	      char	**lud_exts;
	      char	*lud_string;	/* for internal use only */
	  } LDAPURLDesc;

          int ldap_is_ldap_url( char *url );
          int ldap_url_parse( char *url, LDAPURLDesc **ludpp );
          void ldap_free_urldesc( LDAPURLDesc *ludp );

ldap_is_ldap_url() returns 1 if the argument string appears to be a URL of the ldap:// form, and 0 otherwise.

ldap_url_parse() allocates a LDAPURLDesc structure and fills in the fields by parsing the url string. The function returns 0 on success. Fields not present in the URL are set to 0 or NULL. The function returns the following in case of error:

LDAP_URL_ERR_NOTLDAP (1)
The URL doesn't begin with ldap://.
LDAP_URL_ERR_NODN (2)
The URL doesn't contain a Distinguished Name.
LDAP_URL_ERR_BADSCOPE (3)
The URL scope string is invalid.
LDAP_URL_ERR_MEM (4)
Out of memory.
LDAP_URL_ERR_BADEXT (5)
An unsupported LDAP URL extension was present.

The LDAPURLDesc structure should be freed by the caller using ldap_free_urldesc().

Up to Contents

Forward to Utility Functions