]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sql/other.c
Experimental cruft to propagate valid Operation to SASL callbacks.
[openldap] / servers / slapd / back-sql / other.c
1 /*
2  *       Copyright 1999, Dmitry Kovalev <mit@openldap.org>, All rights reserved.
3  *
4  *       Redistribution and use in source and binary forms are permitted only
5  *       as authorized by the OpenLDAP Public License.  A copy of this
6  *       license is available at http://www.OpenLDAP.org/license.html or
7  *       in file LICENSE in the top-level directory of the distribution.
8  */
9
10 #include "portable.h"
11
12 #ifdef SLAPD_SQL
13
14 #include <stdio.h>
15 #include <sys/types.h>
16 #include "slap.h"
17 #include "back-sql.h"
18 #include "sql-wrap.h"
19 #include "entry-id.h"
20
21 int
22 backsql_compare(
23         BackendDB       *bd,
24         Connection      *conn,
25         Operation       *op,
26         struct berval   *dn,
27         struct berval   *ndn,
28         AttributeAssertion *ava )
29 {
30         Debug( LDAP_DEBUG_TRACE, "==>backsql_compare() - not implemented\n",
31                         0, 0, 0 );
32         return 1;
33 }
34
35 int
36 backsql_abandon(
37         BackendDB       *be,
38         Connection      *conn, 
39         Operation       *op, 
40         int             msgid )
41 {
42         Debug( LDAP_DEBUG_TRACE, "==>backsql_abandon()\n", 0, 0, 0 );
43         Debug( LDAP_DEBUG_TRACE, "<==backsql_abandon()\n", 0, 0, 0 );
44         return 0;
45 }
46
47
48 /*
49  * sets the supported operational attributes (if required)
50  */
51
52 int
53 backsql_operational(
54         BackendDB       *be,
55         Connection      *conn, 
56         Operation       *op,
57         Entry           *e,
58         AttributeName   *attrs,
59         int             opattrs,
60         Attribute       **a )
61 {
62
63         backsql_info            *bi = (backsql_info*)be->be_private;
64         SQLHDBC                 dbh = SQL_NULL_HDBC;
65         Attribute               **aa = a;
66         int                     rc;
67
68         Debug( LDAP_DEBUG_TRACE, "==>backsql_operational(): entry '%s'\n",
69                         e->e_nname.bv_val, 0, 0 );
70
71
72         if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
73                 rc = backsql_get_db_conn( be, conn, &dbh );
74                 if ( rc != LDAP_SUCCESS ) {
75                         goto no_connection;
76                 }
77                 
78                 rc = backsql_has_children( bi, dbh, &e->e_nname );
79
80                 switch( rc ) {
81                 case LDAP_COMPARE_TRUE:
82                 case LDAP_COMPARE_FALSE:
83                         *aa = slap_operational_hasSubordinate( rc == LDAP_COMPARE_TRUE );
84                         if ( *aa != NULL ) {
85                                 aa = &(*aa)->a_next;
86                         }
87                         rc = 0;
88                         break;
89
90                 default:
91                         Debug(LDAP_DEBUG_TRACE, 
92                                 "backsql_operational(): "
93                                 "has_children failed( %d)\n", 
94                                 rc, 0, 0 );
95                         rc = 1;
96                         break;
97                 }
98         }
99
100         return rc;
101
102 no_connection:;
103         Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
104                 "could not get connection handle - exiting\n", 
105                 0, 0, 0 );
106         send_ldap_result( conn, op, rc, "", 
107                         rc == LDAP_OTHER ? "SQL-backend error" : "",
108                         NULL, NULL );
109         return 1;
110 }
111
112 #endif /* SLAPD_SQL */
113