]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-passwd/search.c
Updated some items
[openldap] / servers / slapd / back-passwd / search.c
index 7c32656ec2d39b75496070f38e3db95fa6385637..0852a88d1bd7fc5c5b5173478c78e168b9b60bc0 100644 (file)
 #include <pwd.h>
 
 #include "slap.h"
+#include "external.h"
 
-extern time_t          currenttime;
-extern pthread_mutex_t currenttime_mutex;
-
-static Entry   *pw2entry();
+static Entry   *pw2entry(Backend *be, struct passwd *pw);
 
 int
 passwd_back_search(
@@ -75,37 +73,37 @@ passwd_back_search(
 
        for ( pw = getpwent(); pw != NULL; pw = getpwent() ) {
                /* check for abandon */
-               pthread_mutex_lock( &op->o_abandonmutex );
+               ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
                if ( op->o_abandon ) {
-                       pthread_mutex_unlock( &op->o_abandonmutex );
+                       ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
                        endpwent();
                        return( -1 );
                }
-               pthread_mutex_unlock( &op->o_abandonmutex );
-
-               /* check size limit */
-               if ( --slimit == -1 ) {
-                       send_ldap_result( conn, op, LDAP_SIZELIMIT_EXCEEDED,
-                           NULL, NULL );
-                       endpwent();
-                       return( 0 );
-               }
+               ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
 
                /* check time limit */
-               pthread_mutex_lock( &currenttime_mutex );
+               ldap_pvt_thread_mutex_lock( &currenttime_mutex );
                time( &currenttime );
                if ( currenttime > stoptime ) {
-                       pthread_mutex_unlock( &currenttime_mutex );
+                       ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
                        send_ldap_result( conn, op, LDAP_TIMELIMIT_EXCEEDED,
                            NULL, NULL );
                        endpwent();
                        return( 0 );
                }
-               pthread_mutex_unlock( &currenttime_mutex );
+               ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
 
                e = pw2entry( be, pw );
 
                if ( test_filter( be, conn, op, e, filter ) == 0 ) {
+                       /* check size limit */
+                       if ( --slimit == -1 ) {
+                               send_ldap_result( conn, op, LDAP_SIZELIMIT_EXCEEDED,
+                                   NULL, NULL );
+                               endpwent();
+                               return( 0 );
+                       }
+
                        send_search_entry( be, conn, op, e, attrs, attrsonly );
                }
 
@@ -138,7 +136,8 @@ pw2entry( Backend *be, struct passwd *pw )
        e->e_attrs = NULL;
 
        sprintf( buf, "%s@%s", pw->pw_name, be->be_suffix[0] );
-       e->e_dn = strdup( buf );
+       e->e_dn = ch_strdup( buf );
+       e->e_ndn = dn_normalize_case( ch_strdup( buf ) );
 
        val.bv_val = pw->pw_name;
        val.bv_len = strlen( pw->pw_name );