> ----- Original Message -----
> From: "Iain" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, October 28, 2002 12:16 PM
> Subject: [qmailadmin] users not in alphabetical order (ldap)
>

> Hi,
>
> I have noticed a problem where the users are not appearing in alphabetical
> order. This is with qmailadmin 1.0.6, vpopmail 5.3.8 using the LDAP
backend.
> I have around 700 users in the one domain and they do not appear in
> alphabetical order.
>
> ANy ideas?
>
> Iain.

There are two issues that need to be addressed to get this to work :

ISSUE #1
qmailadmin 1.0.6 is not coded to correctly to display the user list in
alphabetical order.
Line 462 of template.c is where the userlist is generated.
It is currently coded like this :

    pw = vauth_getall(Domain,1,0);

The vauth_getall fuction is part of the vpopmail code. The 3rd parameter of
this funtion is supposed to control whether username sorting is applied to
the list. This particular parameter is named "sortit". Because qmail is
setting the sortit parameter to 0, it isnt going to try to display a sorted
list of usernames.

Now, If you are using cdb backend, the list seems to get sorted regardless
of whether sortit is set to 0 or 1. (Maybe the cdb calls always sort the
list automatically?)

If you are using the MySQL backend, you have to set sortit to be 1 to ensure
the "order by pw_name" is appended to the SQL query in vmysql.c - this will
get the userlist sorted by username

Similarly, if you are using the postgres backend, you have to set sortit to
be 1 to ensure the "order by pw_name" is appended to the SQL query in
vpgsql.c  - this will get the userlist sorted by username

But, If you are using LDAP backend, it appears that the sortit parameter is
ignored by the vldap.c. Thus it isnt possible to get a sorted list of
usernames


So, this leads us on to ISSUE #2

For LDAP, the vldap.c in vpopmail needs to be fixed so the sortit parameter
is not ignored

I am no LDAP or C expert, but I guess the fix would be to change the vldap.c
code on line 106 from :

    ret = ldap_search_s(ld, basedn, LDAP_SCOPE_SUBTREE,
                        filter, vldap_attrs, 0, &res);

to something roughly like this

    ret = ldap_search_s(ld, basedn, LDAP_SCOPE_SUBTREE,
                        filter, vldap_attrs, 0, &res);

    if ( sortit == 1 ) {

        if ( ldap_sort_entries( ld, &res, "uid", strcasecmp ) !=
LDAP_SUCCESS ) {
           # error
        }
    }


Maybe one of the coding guru's can implement that one for us?
Also it would be great if the qmailadmin source could be changed to set the
sortit flag by default.

Hope that helps!

Michael.



Reply via email to