httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joon yang <joon_y...@yahoo.com>
Subject using util_ldap question
Date Wed, 14 Jul 2004 17:36:14 GMT
I'm trying to add group authorization to mod_cas, but
want to use ldap entry.

I started tinkering with using the util_ldap.c 's
util_ldap_cache_compare() function.  Does anyone have
any experience tinkering with util_ldap.c in apache?

/* code snippet provided... */
static int is_user_in_ldapgroup(const char *user,
			    const char *group,
			    apr_pool_t *p,
				request_rec *r) {

	int result = 0;
	util_ldap_connection_t *ldc = NULL;


	logd("checking "); logd(user); logd(" against ldap
group: "); logd(group); logd("\n");

    ldc =
util_ldap_connection_find(r,"ldap.server.address",389,"","",0,0);

    result = util_ldap_cache_compare(r, ldc,
"ldap://ldap.server.address", "dc=my,dc=company",
group, user);
    switch(result) {
       case LDAP_COMPARE_TRUE: {
            ap_log_rerror(APLOG_MARK,
APLOG_DEBUG|APLOG_NOERRNO, 0, r, 
              "[%d] auth_ldap authorise: require
group: "
              "authorisation successful (attribute %s)
[%s][%s]",
              getpid(), *group, ldc->reason,
ldap_err2string(result));
            return 1;
		}
       default: {
            ap_log_rerror(APLOG_MARK,
APLOG_DEBUG|APLOG_NOERRNO, 0, r, 
              "[%d] auth_ldap authorise: require
group: "
              "authorisation failed [%s][%s]",
              getpid(), ldc->reason,
ldap_err2string(result));
			return 0;
			}
       }
 
}
/* end code snippet */

The runtime produces the following error.

Memory could not be read.

Unhandled exception in util_ldap.so...Access
violation..

/* code snippet */
LDAP_DECLARE(util_ldap_connection_t
*)util_ldap_connection_find(request_rec *r, const char
*host, int port,
                                              const
char *binddn, const char *bindpw, deref_options deref,
                                              int
secure )
{
    struct util_ldap_connection_t *l, *p;	/* To
traverse the linked list */

    util_ldap_state_t *st = 
        (util_ldap_state_t
*)ap_get_module_config(r->server->module_config,
        &ldap_module);


#if APR_HAS_THREADS
    /* mutex lock this function */
/* code blows up here...*/
    if (!st->mutex) {
        apr_thread_mutex_create(&st->mutex,
APR_THREAD_MUTEX_DEFAULT, st->pool);
    }
    apr_thread_mutex_lock(st->mutex);
#endif

/* code truncated...*/

Any help/guide/suggestion would be appreciated.

JoOn



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail

Mime
View raw message