]> git.sur5r.net Git - openldap/blob - servers/slapd/back-dnssrv/bind.c
20fd959fc591aa8f28babe399e2e22333b7a292a
[openldap] / servers / slapd / back-dnssrv / bind.c
1 /* bind.c - DNS SRV backend bind function */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2000-2007 The OpenLDAP Foundation.
6  * Portions Copyright 2000-2003 Kurt D. Zeilenga.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted only as authorized by the OpenLDAP
11  * Public License.
12  *
13  * A copy of this license is available in the file LICENSE in the
14  * top-level directory of the distribution or, alternatively, at
15  * <http://www.OpenLDAP.org/license.html>.
16  */
17 /* ACKNOWLEDGEMENTS:
18  * This work was originally developed by Kurt D. Zeilenga for inclusion
19  * in OpenLDAP Software.
20  */
21
22
23 #include "portable.h"
24
25 #include <stdio.h>
26
27 #include <ac/socket.h>
28 #include <ac/string.h>
29
30 #include "slap.h"
31 #include "proto-dnssrv.h"
32
33 int
34 dnssrv_back_bind(
35     Operation           *op,
36     SlapReply           *rs )
37 {
38         Debug( LDAP_DEBUG_TRACE, "DNSSRV: bind %s (%d)\n",
39                 op->o_req_dn.bv_val == NULL ? "" : op->o_req_dn.bv_val, 
40                 op->oq_bind.rb_method, NULL );
41                 
42         if ( op->oq_bind.rb_method == LDAP_AUTH_SIMPLE &&
43                 !BER_BVISNULL( &op->oq_bind.rb_cred ) &&
44                 !BER_BVISEMPTY( &op->oq_bind.rb_cred ) )
45         {
46                 Statslog( LDAP_DEBUG_STATS,
47                         "%s DNSSRV BIND dn=\"%s\" provided passwd\n",
48                         op->o_log_prefix,
49                         BER_BVISNULL( &op->o_req_dn ) ? "" : op->o_req_dn.bv_val , 0, 0, 0 );
50
51                 Debug( LDAP_DEBUG_TRACE,
52                         "DNSSRV: BIND dn=\"%s\" provided cleartext password\n",
53                         BER_BVISNULL( &op->o_req_dn ) ? "" : op->o_req_dn.bv_val, 0, 0 );
54
55                 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
56                         "you shouldn't send strangers your password" );
57
58         } else {
59                 Debug( LDAP_DEBUG_TRACE, "DNSSRV: BIND dn=\"%s\"\n",
60                         BER_BVISNULL( &op->o_req_dn ) ? "" : op->o_req_dn.bv_val, 0, 0 );
61
62                 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
63                         "anonymous bind expected" );
64         }
65
66         return 1;
67 }