]> git.sur5r.net Git - openldap/blob - servers/slapd/back-sql/operational.c
make file names more slapd-ish; add attribute inheritance to search attributes; preco...
[openldap] / servers / slapd / back-sql / operational.c
1 /* $OpenLDAP$ */
2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
3  *
4  * Copyright 1999-2004 The OpenLDAP Foundation.
5  * Portions Copyright 1999 Dmitry Kovalev.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 /* ACKNOWLEDGEMENTS:
17  * This work was initially developed by Dmitry Kovalev for inclusion
18  * by OpenLDAP Software.
19  */
20
21 #include "portable.h"
22
23 #ifdef SLAPD_SQL
24
25 #include <stdio.h>
26 #include <sys/types.h>
27
28 #include "slap.h"
29 #include "proto-sql.h"
30
31 /*
32  * sets the supported operational attributes (if required)
33  */
34
35 int
36 backsql_operational(
37         Operation       *op,
38         SlapReply       *rs,
39         int             opattrs,
40         Attribute       **a )
41 {
42
43         backsql_info            *bi = (backsql_info*)op->o_bd->be_private;
44         SQLHDBC                 dbh = SQL_NULL_HDBC;
45         Attribute               **aa = a;
46         int                     rc = 0;
47
48         Debug( LDAP_DEBUG_TRACE, "==>backsql_operational(): entry '%s'\n",
49                         rs->sr_entry->e_nname.bv_val, 0, 0 );
50
51
52         if ( ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) ) 
53                         && attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL ) {
54                 
55                 rc = backsql_get_db_conn( op, &dbh );
56                 if ( rc != LDAP_SUCCESS ) {
57                         Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
58                                 "could not get connection handle - exiting\n", 
59                                 0, 0, 0 );
60                         return 1;
61                 }
62                 
63                 rc = backsql_has_children( bi, dbh, &rs->sr_entry->e_nname );
64
65                 switch( rc ) {
66                 case LDAP_COMPARE_TRUE:
67                 case LDAP_COMPARE_FALSE:
68                         *aa = slap_operational_hasSubordinate( rc == LDAP_COMPARE_TRUE );
69                         if ( *aa != NULL ) {
70                                 aa = &(*aa)->a_next;
71                         }
72                         rc = 0;
73                         break;
74
75                 default:
76                         Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
77                                 "has_children failed( %d)\n", rc, 0, 0 );
78                         rc = 1;
79                         break;
80                 }
81         }
82
83         Debug( LDAP_DEBUG_TRACE, "<==backsql_operational()\n", 0, 0, 0);
84
85         return rc;
86 }
87
88 #endif /* SLAPD_SQL */
89