You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by joon yang <jo...@yahoo.com> on 2004/07/14 19:31:42 UTC

[users@httpd] Trying to create a module using util_ldap.so

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!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org