You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by karim Bendadda <ka...@gmail.com> on 2008/01/10 14:46:49 UTC

Problem with directives

Hi All,

I'm creating a custom module wish connects to an Ldap directory (openldap)
and  other operations...

1- I tried to add directives to the module on the httpd.conf file :

*<Location /name_module>
 url http:\\10.114.20.8\myopenldap
 port 389
 baseDn someone
</Location>*


2- in my module I have created a structure:

*typedef struct mod_name{
 apr_pool_t    *mpool;
  const char *url_LDAP;
** int num_port;
 const char *base_dn;
}mod_name_conf;

*3- After I have created the table:

*static const command_rec **name**_cmds[] = {

    AP_INIT_TAKE1("url**", ap_set_string_slot,
                  (void*)APR_OFFSETOF(mod_auth_conf, url_LDAP), OR_ALL,
                  "url of openldap"),

    AP_INIT_TAKE1("port", ap_set_int_slot,
                  (void*)APR_OFFSETOF(mod_auth_conf, num_port), OR_ALL,
                  "port of openldap"),

    AP_INIT_TAKE1("**baseDn**", ap_set_string_slot,
                  (void*)APR_OFFSETOF(mod_auth_conf, base_dn), OR_ALL,
                  "base DN of LDAP"),
    {NULL}
};

*4- then I initialize the configuration

*static void *auth_chorus_conf(apr_pool_t *pool, char *x)
{
    mod_auth_conf *mod_auth_conf_ptr;
    if (mod_auth_conf_ptr=apr_pcalloc(pool, sizeof(mod_auth_conf))){
    mod_auth_conf_ptr->mpool=pool;
    mod_auth_conf_ptr->url=NULL;
    mod_auth_conf_ptr->port=0;
    mod_auth_conf_ptr->baseDn=NULL;
    return mod_auth_conf_ptr;
    }
    else
    return NULL;
}*
*
*5- And finally to call the ldap initialization for example I use:

*ldap_init(mod_auth_conf_ptr->url, mod_auth_conf_ptr->port );

module AP_MODULE_DECLARE_DATA **name_**module = {
    STANDARD20_MODULE_STUFF,
    **name_**conf,
    NULL,
    NULL,
    NULL,
    name_cmds,
    name_hooks
};

*
And it doesn't work!! (it works using the url and the port number without
the directives directly in the module) I have somethig like this when using
apr_perror:

*[Thu Jan 10 10:17:23 2008] [notice] [client 10.75.197.168] url_ldap :
(null) , port : \xc0\x13\xe1\xb7\xc0\x13\xe1\xb7Pw\x18\bPw\x18\b

and finally my question:

*Did I forget something ??
-- 
Karim

[Resolved]Re: Problem with directives

Posted by karim Bendadda <ka...@gmail.com>.
Thank you Joe for your answer!

>I'm not sure port is the best one to use.  Perhaps something more
>specific to your module, such as MyLDAPPort, or even relying on the
>ldaputil.c settings to set up that information for you.

You are right, I have changed it

>It appears that someone's keyboard put in a few extra asterisks on
>that.  I see too many on a num_port line.

That's my new keyboard!! the're no asterisks!

I don't know if there is a best practice for choosing directives but it will
be intersting to have one

Concerning my problem I found the solution here:
http://threebit.net/tutorials/apache2_modules/tut2/tutorial2.html


Thak you for your help!!


On Jan 10, 2008 10:02 PM, Joe Lewis <jo...@joe-lewis.com> wrote:

> karim Bendadda wrote:
> > *<Location /name_module>
> >  url http:\\10.114.20.8\myopenldap
> >  port 389
> >  baseDn someone
> > </Location>*
> >
>
> I'm not sure port is the best one to use.  Perhaps something more
> specific to your module, such as MyLDAPPort, or even relying on the
> ldaputil.c settings to set up that information for you.






>
> > *typedef struct mod_name{
> >  apr_pool_t    *mpool;
> >   const char *url_LDAP;
> > ** int num_port;
> >  const char *base_dn;
> > }mod_name_conf;
> >
>
> It appears that someone's keyboard put in a few extra asterisks on
> that.  I see too many on a num_port line.
>
>
> > *static const command_rec **name**_cmds[] = {
> >
> >     AP_INIT_TAKE1("url**", ap_set_string_slot,
> >                   (void*)APR_OFFSETOF(mod_auth_conf, url_LDAP), OR_ALL,
> >                   "url of openldap"),
> >
> >     AP_INIT_TAKE1("port", ap_set_int_slot,
> >                   (void*)APR_OFFSETOF(mod_auth_conf, num_port), OR_ALL,
> >                   "port of openldap"),
> >
> >     AP_INIT_TAKE1("**baseDn**", ap_set_string_slot,
> >                   (void*)APR_OFFSETOF(mod_auth_conf, base_dn), OR_ALL,
> >                   "base DN of LDAP"),
> >     {NULL}
> > };
> >
>
> One - I see WAY too many asterisks.  There should be no asterisks in the
> directive lines.  Please remove them, and choose better directives.
>
> Preface those directives with something more specific, please.  For
> example, if you LDAP module is a translate function that uses LDAP to
> specify which file to retrieve, then you might call the directives
> LDAPTranslateURL, LDAPTranslatePort, and LDAPTranslateBaseDN (this is
> just a set of examples).
>
> Joe
>



-- 
Karim

Re: Problem with directives

Posted by Joe Lewis <jo...@joe-lewis.com>.
karim Bendadda wrote:
> *<Location /name_module>
>  url http:\\10.114.20.8\myopenldap
>  port 389
>  baseDn someone
> </Location>*
>   


I'm not sure port is the best one to use.  Perhaps something more 
specific to your module, such as MyLDAPPort, or even relying on the 
ldaputil.c settings to set up that information for you.


> *typedef struct mod_name{
>  apr_pool_t    *mpool;
>   const char *url_LDAP;
> ** int num_port;
>  const char *base_dn;
> }mod_name_conf;
>   

It appears that someone's keyboard put in a few extra asterisks on 
that.  I see too many on a num_port line.


> *static const command_rec **name**_cmds[] = {
>
>     AP_INIT_TAKE1("url**", ap_set_string_slot,
>                   (void*)APR_OFFSETOF(mod_auth_conf, url_LDAP), OR_ALL,
>                   "url of openldap"),
>
>     AP_INIT_TAKE1("port", ap_set_int_slot,
>                   (void*)APR_OFFSETOF(mod_auth_conf, num_port), OR_ALL,
>                   "port of openldap"),
>
>     AP_INIT_TAKE1("**baseDn**", ap_set_string_slot,
>                   (void*)APR_OFFSETOF(mod_auth_conf, base_dn), OR_ALL,
>                   "base DN of LDAP"),
>     {NULL}
> };
>   

One - I see WAY too many asterisks.  There should be no asterisks in the 
directive lines.  Please remove them, and choose better directives.

Preface those directives with something more specific, please.  For 
example, if you LDAP module is a translate function that uses LDAP to 
specify which file to retrieve, then you might call the directives 
LDAPTranslateURL, LDAPTranslatePort, and LDAPTranslateBaseDN (this is 
just a set of examples).

Joe