]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/bind.c
notices and acknowledgements
[openldap] / servers / slapd / back-ldap / bind.c
1 /* bind.c - ldap backend bind function */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1999-2003 The OpenLDAP Foundation.
6  * Portions Copyright 2000-2003 Pierangelo Masarati.
7  * Portions Copyright 1999-2003 Howard Chu.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted only as authorized by the OpenLDAP
12  * Public License.
13  *
14  * A copy of this license is available in the file LICENSE in the
15  * top-level directory of the distribution or, alternatively, at
16  * <http://www.OpenLDAP.org/license.html>.
17  */
18 /* ACKNOWLEDGEMENTS:
19  * This work was initially developed by the Howard Chu for inclusion
20  * in OpenLDAP Software and subsequently enhanced by Pierangelo
21  * Masarati.
22  */
23
24 #include "portable.h"
25
26 #include <stdio.h>
27
28 #include <ac/socket.h>
29 #include <ac/string.h>
30
31
32 #define AVL_INTERNAL
33 #include "slap.h"
34 #include "back-ldap.h"
35
36 #define PRINT_CONNTREE 0
37
38 static LDAP_REBIND_PROC ldap_back_rebind;
39
40 int
41 ldap_back_bind(
42     Operation           *op,
43     SlapReply           *rs )
44 {
45         struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;
46         struct ldapconn *lc;
47
48         struct berval mdn = { 0, NULL };
49         int rc = 0;
50         ber_int_t msgid;
51         dncookie dc;
52
53         lc = ldap_back_getconn(op, rs);
54         if ( !lc ) {
55                 return( -1 );
56         }
57
58         /*
59          * Rewrite the bind dn if needed
60          */
61         dc.rwmap = &li->rwmap;
62 #ifdef ENABLE_REWRITE
63         dc.conn = op->o_conn;
64         dc.rs = rs;
65         dc.ctx = "bindDn";
66 #else
67         dc.tofrom = 1;
68         dc.normalized = 0;
69 #endif
70         if ( ldap_back_dn_massage( &dc, &op->o_req_dn, &mdn ) ) {
71                 send_ldap_result( op, rs );
72                 return -1;
73         }
74
75         if ( lc->bound_dn.bv_val ) {
76                 ch_free( lc->bound_dn.bv_val );
77                 lc->bound_dn.bv_len = 0;
78                 lc->bound_dn.bv_val = NULL;
79         }
80         lc->bound = 0;
81         /* method is always LDAP_AUTH_SIMPLE if we got here */
82         rs->sr_err = ldap_sasl_bind(lc->ld, mdn.bv_val, LDAP_SASL_SIMPLE,
83                 &op->oq_bind.rb_cred, op->o_ctrls, NULL, &msgid);
84         rc = ldap_back_op_result( lc, op, rs, msgid, 1 );
85         if (rc == LDAP_SUCCESS) {
86                 lc->bound = 1;
87                 if ( mdn.bv_val != op->o_req_dn.bv_val ) {
88                         lc->bound_dn = mdn;
89                 } else {
90                         ber_dupbv( &lc->bound_dn, &op->o_req_dn );
91                 }
92                 mdn.bv_val = NULL;
93
94                 if ( li->savecred ) {
95                         if ( lc->cred.bv_val ) {
96                                 memset( lc->cred.bv_val, 0, lc->cred.bv_len );
97                                 ch_free( lc->cred.bv_val );
98                         }
99                         ber_dupbv( &lc->cred, &op->oq_bind.rb_cred );
100                         ldap_set_rebind_proc( lc->ld, ldap_back_rebind, lc );
101                 }
102         }
103
104         /* must re-insert if local DN changed as result of bind */
105         if ( lc->bound && !bvmatch(&op->o_req_ndn, &lc->local_dn ) ) {
106                 int lerr;
107
108                 ldap_pvt_thread_mutex_lock( &li->conn_mutex );
109                 lc = avl_delete( &li->conntree, (caddr_t)lc,
110                                 ldap_back_conn_cmp );
111                 if ( lc->local_dn.bv_val )
112                         ch_free( lc->local_dn.bv_val );
113                 ber_dupbv( &lc->local_dn, &op->o_req_ndn );
114                 lerr = avl_insert( &li->conntree, (caddr_t)lc,
115                         ldap_back_conn_cmp, ldap_back_conn_dup );
116                 ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
117                 if ( lerr == -1 ) {
118                         ldap_back_conn_free( lc );
119                 }
120         }
121
122         if ( mdn.bv_val && mdn.bv_val != op->o_req_dn.bv_val ) {
123                 free( mdn.bv_val );
124         }
125
126         return( rc );
127 }
128
129 /*
130  * ldap_back_conn_cmp
131  *
132  * compares two struct ldapconn based on the value of the conn pointer;
133  * used by avl stuff
134  */
135 int
136 ldap_back_conn_cmp(
137         const void *c1,
138         const void *c2
139         )
140 {
141         const struct ldapconn *lc1 = (const struct ldapconn *)c1;
142         const struct ldapconn *lc2 = (const struct ldapconn *)c2;
143         int rc;
144         
145         /* If local DNs don't match, it is definitely not a match */
146         if ( ( rc = ber_bvcmp( &lc1->local_dn, &lc2->local_dn )) )
147                 return rc;
148
149         /* For shared sessions, conn is NULL. Only explicitly
150          * bound sessions will have non-NULL conn.
151          */
152         return SLAP_PTRCMP(lc1->conn, lc2->conn);
153 }
154
155 /*
156  * ldap_back_conn_dup
157  *
158  * returns -1 in case a duplicate struct ldapconn has been inserted;
159  * used by avl stuff
160  */
161 int
162 ldap_back_conn_dup(
163         void *c1,
164         void *c2
165         )
166 {
167         struct ldapconn *lc1 = (struct ldapconn *)c1;
168         struct ldapconn *lc2 = (struct ldapconn *)c2;
169
170         /* Cannot have more than one shared session with same DN */
171         if ( dn_match( &lc1->local_dn, &lc2->local_dn ) &&
172                  lc1->conn == lc2->conn ) return -1;
173                 
174         return 0;
175 }
176
177 #if PRINT_CONNTREE > 0
178 static void ravl_print( Avlnode *root, int depth )
179 {
180         int     i;
181         struct ldapconn *lc;
182         
183         if ( root == 0 )
184                 return;
185         
186         ravl_print( root->avl_right, depth+1 );
187         
188         for ( i = 0; i < depth; i++ )
189                 printf( "   " );
190
191         lc = root->avl_data;
192         printf( "lc(%lx) local(%s) conn(%lx) %d\n",
193                         lc, lc->local_dn.bv_val, lc->conn, root->avl_bf );
194         
195         ravl_print( root->avl_left, depth+1 );
196 }
197
198 static void myprint( Avlnode *root )
199 {
200         printf( "********\n" );
201         
202         if ( root == 0 )
203                 printf( "\tNULL\n" );
204
205         else
206                 ravl_print( root, 0 );
207         
208         printf( "********\n" );
209 }
210 #endif /* PRINT_CONNTREE */
211
212 struct ldapconn *
213 ldap_back_getconn(Operation *op, SlapReply *rs)
214 {
215         struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private;
216         struct ldapconn *lc, lc_curr;
217         LDAP *ld;
218         int is_priv = 0;
219
220         /* Searches for a ldapconn in the avl tree */
221
222         /* Explicit binds must not be shared */
223         if ( op->o_tag == LDAP_REQ_BIND
224                 || (op->o_conn
225                   && (op->o_bd == op->o_conn->c_authz_backend ))) {
226                 lc_curr.conn = op->o_conn;
227         } else {
228                 lc_curr.conn = NULL;
229         }
230         
231         /* Internal searches are privileged and shared. So is root. */
232         if ( op->o_do_not_cache || be_isroot( li->be, &op->o_ndn ) ) {
233                 lc_curr.local_dn = li->be->be_rootndn;
234                 lc_curr.conn = NULL;
235                 is_priv = 1;
236         } else {
237                 lc_curr.local_dn = op->o_ndn;
238         }
239
240         ldap_pvt_thread_mutex_lock( &li->conn_mutex );
241         lc = (struct ldapconn *)avl_find( li->conntree, 
242                 (caddr_t)&lc_curr, ldap_back_conn_cmp );
243         ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
244
245         /* Looks like we didn't get a bind. Open a new session... */
246         if (!lc) {
247                 int vers = op->o_protocol;
248                 rs->sr_err = ldap_initialize(&ld, li->url);
249                 
250                 if (rs->sr_err != LDAP_SUCCESS) {
251                         rs->sr_err = ldap_back_map_result(rs);
252                         if (rs->sr_text == NULL) {
253                                 rs->sr_text = "ldap_initialize() failed";
254                         }
255                         if (op->o_conn) send_ldap_result( op, rs );
256                         rs->sr_text = NULL;
257                         return( NULL );
258                 }
259                 /* Set LDAP version. This will always succeed: If the client
260                  * bound with a particular version, then so can we.
261                  */
262                 ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION,
263                                 (const void *)&vers);
264                 /* FIXME: configurable? */
265                 ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_ON);
266
267                 lc = (struct ldapconn *)ch_malloc(sizeof(struct ldapconn));
268                 lc->conn = lc_curr.conn;
269                 lc->ld = ld;
270                 ber_dupbv( &lc->local_dn, &lc_curr.local_dn );
271
272 #ifdef ENABLE_REWRITE
273                 /*
274                  * Sets a cookie for the rewrite session
275                  *
276                  * FIXME: the o_conn might be no longer valid,
277                  * since we may have different entries
278                  * for the same connection
279                  */
280                 ( void )rewrite_session_init( li->rwmap.rwm_rw, op->o_conn );
281 #endif /* ENABLE_REWRITE */
282
283                 ldap_pvt_thread_mutex_init( &lc->lc_mutex );
284
285                 if ( is_priv ) {
286                         ber_dupbv( &lc->cred, &li->bindpw );
287                         ber_dupbv( &lc->bound_dn, &li->binddn );
288                 } else {
289                         lc->cred.bv_len = 0;
290                         lc->cred.bv_val = NULL;
291                         lc->bound_dn.bv_val = NULL;
292                         lc->bound_dn.bv_len = 0;
293                         if ( op->o_conn && op->o_conn->c_dn.bv_len != 0
294                                         && ( op->o_bd == op->o_conn->c_authz_backend ) ) {
295                                 
296                                 dncookie dc;
297                                 struct berval bv;
298
299                                 /*
300                                  * Rewrite the bind dn if needed
301                                  */
302                                 dc.rwmap = &li->rwmap;
303 #ifdef ENABLE_REWRITE
304                                 dc.conn = op->o_conn;
305                                 dc.rs = rs;
306                                 dc.ctx = "bindDn";
307 #else
308                                 dc.tofrom = 1;
309                                 dc.normalized = 0;
310 #endif
311
312                                 if ( ldap_back_dn_massage( &dc, &op->o_conn->c_dn, &bv ) ) {
313                                         send_ldap_result( op, rs );
314                                         return NULL;
315                                 }
316
317                                 if ( bv.bv_val == op->o_conn->c_dn.bv_val ) {
318                                         ber_dupbv( &lc->bound_dn, &bv );
319                                 } else {
320                                         lc->bound_dn = bv;
321                                 }
322                         }
323                 }
324
325                 lc->bound = 0;
326
327                 /* Inserts the newly created ldapconn in the avl tree */
328                 ldap_pvt_thread_mutex_lock( &li->conn_mutex );
329                 rs->sr_err = avl_insert( &li->conntree, (caddr_t)lc,
330                         ldap_back_conn_cmp, ldap_back_conn_dup );
331
332 #if PRINT_CONNTREE > 0
333                 myprint( li->conntree );
334 #endif /* PRINT_CONNTREE */
335         
336                 ldap_pvt_thread_mutex_unlock( &li->conn_mutex );
337
338 #ifdef NEW_LOGGING
339                 LDAP_LOG( BACK_LDAP, INFO, 
340                         "ldap_back_getconn: conn %p inserted\n", (void *) lc, 0, 0);
341 #else /* !NEW_LOGGING */
342                 Debug( LDAP_DEBUG_TRACE,
343                         "=>ldap_back_getconn: conn %p inserted\n", (void *) lc, 0, 0 );
344 #endif /* !NEW_LOGGING */
345         
346                 /* Err could be -1 in case a duplicate ldapconn is inserted */
347                 if ( rs->sr_err != 0 ) {
348                         ldap_back_conn_free( lc );
349                         if (op->o_conn) {
350                                 send_ldap_error( op, rs, LDAP_OTHER,
351                                 "internal server error" );
352                         }
353                         return( NULL );
354                 }
355         } else {
356 #ifdef NEW_LOGGING
357                 LDAP_LOG( BACK_LDAP, INFO, 
358                         "ldap_back_getconn: conn %p fetched\n", 
359                         (void *) lc, 0, 0 );
360 #else /* !NEW_LOGGING */
361                 Debug( LDAP_DEBUG_TRACE,
362                         "=>ldap_back_getconn: conn %p fetched\n", (void *) lc, 0, 0 );
363 #endif /* !NEW_LOGGING */
364         }
365         
366         return( lc );
367 }
368
369 /*
370  * ldap_back_dobind
371  *
372  * Note: as the check for the value of lc->bound was already here, I removed
373  * it from all the callers, and I made the function return the flag, so
374  * it can be used to simplify the check.
375  */
376 int
377 ldap_back_dobind( struct ldapconn *lc, Operation *op, SlapReply *rs )
378 {       
379         struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private;
380         int rc;
381         ber_int_t msgid;
382
383         ldap_pvt_thread_mutex_lock( &lc->lc_mutex );
384         if ( !lc->bound ) {
385 #ifdef LDAP_BACK_PROXY_AUTHZ
386                 int     gotit = 0;
387 #if 0
388                 /*
389                  * FIXME: we need to let clients use proxyAuthz
390                  * otherwise we cannot do symmetric pools of servers;
391                  * we have to live with the fact that a user can
392                  * authorize itself as any ID that is allowed
393                  * by the saslAuthzTo directive of the "binddn".
394                  */
395                 /*
396                  * NOTE: current Proxy Authorization specification
397                  * and implementation do not allow proxy authorization
398                  * control to be provided with Bind requests
399                  */
400                 gotit = op->o_proxy_authz;
401 #endif
402
403                 /*
404                  * if no bind took place yet, but the connection is bound
405                  * and the binddn is set, then bind with binddn and 
406                  * explicitly add proxyAuthz control to every operation
407                  * with the dn bound to the connection as control value.
408                  */
409                 if ( ( lc->bound_dn.bv_val == NULL || lc->bound_dn.bv_len == 0 )
410                                 && ( op->o_conn && op->o_conn->c_dn.bv_val != NULL && op->o_conn->c_dn.bv_len != 0 )
411                                 && ( li->binddn.bv_val != NULL && li->binddn.bv_len != 0 ) 
412                                 && ! gotit ) {
413                         rs->sr_err = ldap_sasl_bind(lc->ld, li->binddn.bv_val,
414                                 LDAP_SASL_SIMPLE, &li->bindpw, NULL, NULL, &msgid);
415
416                 } else
417 #endif /* LDAP_BACK_PROXY_AUTHZ */
418                 {
419                         rs->sr_err = ldap_sasl_bind(lc->ld, lc->bound_dn.bv_val,
420                                 LDAP_SASL_SIMPLE, &lc->cred, NULL, NULL, &msgid);
421                 }
422                 
423                 rc = ldap_back_op_result( lc, op, rs, msgid, 0 );
424                 if (rc == LDAP_SUCCESS) {
425                         lc->bound = 1;
426                 }
427         }
428         rc = lc->bound;
429         ldap_pvt_thread_mutex_unlock( &lc->lc_mutex );
430         return rc;
431 }
432
433 /*
434  * ldap_back_rebind
435  *
436  * This is a callback used for chasing referrals using the same
437  * credentials as the original user on this session.
438  */
439 static int 
440 ldap_back_rebind( LDAP *ld, LDAP_CONST char *url, ber_tag_t request,
441         ber_int_t msgid, void *params )
442 {
443         struct ldapconn *lc = params;
444
445         return ldap_bind_s( ld, lc->bound_dn.bv_val, lc->cred.bv_val, LDAP_AUTH_SIMPLE );
446 }
447
448 /* Map API errors to protocol errors... */
449
450 int
451 ldap_back_map_result(SlapReply *rs)
452 {
453         switch(rs->sr_err)
454         {
455         case LDAP_SERVER_DOWN:
456                 return LDAP_UNAVAILABLE;
457         case LDAP_LOCAL_ERROR:
458                 return LDAP_OTHER;
459         case LDAP_ENCODING_ERROR:
460         case LDAP_DECODING_ERROR:
461                 return LDAP_PROTOCOL_ERROR;
462         case LDAP_TIMEOUT:
463                 return LDAP_UNAVAILABLE;
464         case LDAP_AUTH_UNKNOWN:
465                 return LDAP_AUTH_METHOD_NOT_SUPPORTED;
466         case LDAP_FILTER_ERROR:
467                 rs->sr_text = "Filter error";
468                 return LDAP_OTHER;
469         case LDAP_USER_CANCELLED:
470                 rs->sr_text = "User cancelled";
471                 return LDAP_OTHER;
472         case LDAP_PARAM_ERROR:
473                 return LDAP_PROTOCOL_ERROR;
474         case LDAP_NO_MEMORY:
475                 return LDAP_OTHER;
476         case LDAP_CONNECT_ERROR:
477                 return LDAP_UNAVAILABLE;
478         case LDAP_NOT_SUPPORTED:
479                 return LDAP_UNWILLING_TO_PERFORM;
480         case LDAP_CONTROL_NOT_FOUND:
481                 return LDAP_PROTOCOL_ERROR;
482         case LDAP_NO_RESULTS_RETURNED:
483                 return LDAP_NO_SUCH_OBJECT;
484         case LDAP_MORE_RESULTS_TO_RETURN:
485                 rs->sr_text = "More results to return";
486                 return LDAP_OTHER;
487         case LDAP_CLIENT_LOOP:
488         case LDAP_REFERRAL_LIMIT_EXCEEDED:
489                 return LDAP_LOOP_DETECT;
490         default:
491                 if LDAP_API_ERROR(rs->sr_err)
492                         return LDAP_OTHER;
493                 else
494                         return rs->sr_err;
495         }
496 }
497
498 int
499 ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
500         ber_int_t msgid, int sendok)
501 {
502         struct ldapinfo *li = (struct ldapinfo *)op->o_bd->be_private;
503         char *match = NULL;
504         LDAPMessage *res;
505         char *text = NULL;
506
507         rs->sr_text = NULL;
508         rs->sr_matched = NULL;
509
510         if (rs->sr_err == LDAP_SUCCESS) {
511                 if (ldap_result(lc->ld, msgid, 1, NULL, &res) == -1) {
512                         ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER,
513                                         &rs->sr_err);
514                 } else {
515                         int rc = ldap_parse_result(lc->ld, res, &rs->sr_err,
516                                         &match, &text, NULL, NULL, 1);
517                         rs->sr_text = text;
518                         if (rc != LDAP_SUCCESS) rs->sr_err = rc;
519                 }
520         }
521
522         if (rs->sr_err != LDAP_SUCCESS) {
523                 rs->sr_err = ldap_back_map_result(rs);
524
525                 /* internal ops must not reply to client */
526                 if ( op->o_conn && !op->o_do_not_cache && match ) {
527                         struct berval dn, mdn;
528                         dncookie dc;
529
530                         dc.rwmap = &li->rwmap;
531 #ifdef ENABLE_REWRITE
532                         dc.conn = op->o_conn;
533                         dc.rs = rs;
534                         dc.ctx = "matchedDn";
535 #else
536                         dc.tofrom = 0;
537                         dc.normalized = 0;
538 #endif
539                         ber_str2bv(match, 0, 0, &dn);
540                         ldap_back_dn_massage(&dc, &dn, &mdn);
541                         rs->sr_matched = mdn.bv_val;
542                                 
543                 }
544         }
545         if (op->o_conn && (sendok || rs->sr_err != LDAP_SUCCESS)) {
546                 send_ldap_result( op, rs );
547         }
548         if ( match ) {
549                 if ( rs->sr_matched != match ) {
550                         free( (char *)rs->sr_matched );
551                 }
552                 rs->sr_matched = NULL;
553                 ldap_memfree( match );
554         }
555         if ( text ) {
556                 ldap_memfree( text );
557         }
558         rs->sr_text = NULL;
559         return( (rs->sr_err == LDAP_SUCCESS) ? 0 : -1 );
560 }
561
562 #ifdef LDAP_BACK_PROXY_AUTHZ
563 /*
564  * ldap_back_proxy_authz_ctrl() prepends a proxyAuthz control
565  * to existing server-side controls if required; if not,
566  * the existing server-side controls are placed in *pctrls.
567  * The caller, after using the controls in client API 
568  * operations, if ( *pctrls != op->o_ctrls ), should
569  * free( (*pctrls)[ 0 ] ) and free( *pctrls ).
570  * The function returns success if the control could
571  * be added if required, or if it did nothing; in the future,
572  * it might return some error if it failed.
573  * 
574  * if no bind took place yet, but the connection is bound
575  * and the binddn is set, then bind with binddn and 
576  * explicitly add proxyAuthz control to every operation
577  * with the dn bound to the connection as control value.
578  *
579  * If no server-side controls are defined for the operation,
580  * simply add the proxyAuthz control; otherwise, if the
581  * proxyAuthz control is not already set, add it as
582  * the first one (FIXME: is controls order significant
583  * for security?).
584  */
585 int
586 ldap_back_proxy_authz_ctrl(
587                 struct ldapconn *lc,
588                 Operation       *op,
589                 SlapReply       *rs,
590                 LDAPControl     ***pctrls )
591 {
592         struct ldapinfo *li = (struct ldapinfo *) op->o_bd->be_private;
593         LDAPControl     **ctrls = NULL;
594
595         *pctrls = NULL;
596
597         if ( ( lc->bound_dn.bv_val == NULL || lc->bound_dn.bv_len == 0 )
598                         && ( op->o_conn && op->o_conn->c_dn.bv_val != NULL && op->o_conn->c_dn.bv_len != 0 )
599                         && ( li->binddn.bv_val != NULL && li->binddn.bv_len != 0 ) ) {
600                 int     i = 0;
601
602                 if ( !op->o_proxy_authz ) {
603                         ctrls = ch_malloc( sizeof( LDAPControl * ) * (i + 2) );
604                         ctrls[ 0 ] = ch_malloc( sizeof( LDAPControl ) );
605                         
606                         ctrls[ 0 ]->ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
607                         ctrls[ 0 ]->ldctl_iscritical = 1;
608                         ctrls[ 0 ]->ldctl_value.bv_len = op->o_conn->c_dn.bv_len + 3;
609                         ctrls[ 0 ]->ldctl_value.bv_val = ch_malloc( ctrls[ 0 ]->ldctl_value.bv_len + 1 );
610                         AC_MEMCPY( ctrls[ 0 ]->ldctl_value.bv_val, "dn:", sizeof( "dn:" ) - 1 );
611                         AC_MEMCPY( ctrls[ 0 ]->ldctl_value.bv_val + sizeof( "dn:") - 1,
612                                         op->o_conn->c_dn.bv_val, op->o_conn->c_dn.bv_len + 1 );
613
614                         if ( op->o_ctrls ) {
615                                 for ( i = 0; op->o_ctrls[ i ]; i++ ) {
616                                         ctrls[ i + 1 ] = op->o_ctrls[ i ];
617                                 }
618                         }
619                         ctrls[ i + 1 ] = NULL;
620
621                 } else {
622                         /*
623                          * FIXME: we do not want to perform proxyAuthz
624                          * on behalf of the client, because this would
625                          * be performed with "binddn" privileges.
626                          *
627                          * This might actually be too strict, since
628                          * the "binddn" saslAuthzTo, and each entry's
629                          * saslAuthzFrom attributes may be crafted
630                          * to avoid unwanted proxyAuthz to take place.
631                          */
632 #if 0
633                         rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
634                         rs->sr_text = "proxyAuthz not allowed within namingContext";
635 #endif
636                 }
637         }
638
639         if ( ctrls == NULL ) {
640                 ctrls = op->o_ctrls;
641         }
642
643         *pctrls = ctrls;
644         
645         return rs->sr_err;
646 }
647 #endif /* LDAP_BACK_PROXY_AUTHZ */