]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/config.c
Fix checkpoint task start/stop
[openldap] / servers / slapd / back-bdb / config.c
1 /* config.c - bdb backend configuration file routine */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2000-2005 The OpenLDAP Foundation.
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
17 #include "portable.h"
18
19 #include <stdio.h>
20 #include <ac/string.h>
21
22 #include "back-bdb.h"
23
24 #include "config.h"
25
26 #include "lutil.h"
27 #include "ldap_rq.h"
28
29 #ifdef DB_DIRTY_READ
30 #       define  SLAP_BDB_ALLOW_DIRTY_READ
31 #endif
32
33 static ObjectClass *bdb_oc;
34
35 static ConfigDriver bdb_cf_oc, bdb_cf_gen;
36
37 enum {
38         BDB_CHKPT = 1,
39         BDB_CONFIG,
40         BDB_DIRECTORY,
41         BDB_NOSYNC,
42         BDB_DIRTYR,
43         BDB_INDEX,
44         BDB_LOCKD,
45         BDB_SSTACK
46 };
47
48 static ConfigTable bdbcfg[] = {
49         { "", "", 0, 0, 0, ARG_MAGIC,
50                 bdb_cf_oc, NULL, NULL, NULL },
51         { "directory", "dir", 2, 2, 0, ARG_STRING|ARG_MAGIC|BDB_DIRECTORY,
52                 bdb_cf_gen, "( OLcfgDbAt:0.1 NAME 'olcDbDirectory' "
53                         "DESC 'Directory for database content' "
54                         "EQUALITY caseIgnoreMatch "
55                         "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
56         { "cachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET,
57                 (void *)offsetof(struct bdb_info, bi_cache.c_maxsize),
58                 "( OLcfgDbAt:1.1 NAME 'olcDbCacheSize' "
59                         "DESC 'Entry cache size in entries' "
60                         "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
61         { "checkpoint", "kbyte> <min", 3, 3, 0, ARG_MAGIC|BDB_CHKPT,
62                 bdb_cf_gen, "( OLcfgDbAt:1.2 NAME 'olcDbCheckpoint' "
63                         "DESC 'Database checkpoint interval in kbytes and minutes' "
64                         "SYNTAX OMsDirectoryString SINGLE-VALUE )",NULL, NULL },
65         { "dbconfig", "DB_CONFIG setting", 3, 0, 0, ARG_MAGIC|BDB_CONFIG,
66                 bdb_cf_gen, "( OLcfgDbAt:1.3 NAME 'olcDbConfig' "
67                         "DESC 'BerkeleyDB DB_CONFIG configuration directives' "
68                         "SYNTAX OMsDirectoryString )",NULL, NULL },
69         { "dbnosync", NULL, 1, 2, 0, ARG_ON_OFF|ARG_MAGIC|BDB_NOSYNC,
70                 bdb_cf_gen, "( OLcfgDbAt:1.4 NAME 'olcDbNoSync' "
71                         "DESC 'Disable synchronous database writes' "
72                         "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
73         { "dirtyread", NULL, 1, 2, 0,
74 #ifdef SLAP_BDB_ALLOW_DIRTY_READ
75                 ARG_ON_OFF|ARG_MAGIC|BDB_DIRTYR, bdb_cf_gen,
76 #else
77                 ARG_IGNORED, NULL,
78 #endif
79                 "( OLcfgDbAt:1.5 NAME 'olcDbDirtyRead' "
80                 "DESC 'Allow reads of uncommitted data' "
81                 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
82         { "idlcachesize", "size", 2, 2, 0, ARG_INT|ARG_OFFSET,
83                 (void *)offsetof(struct bdb_info,bi_idl_cache_max_size),
84                 "( OLcfgDbAt:1.6 NAME 'olcDbIDLcacheSize' "
85                 "DESC 'IDL cache size in IDLs' "
86                 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
87         { "index", "attr> <[pres,eq,approx,sub]", 2, 3, 0, ARG_MAGIC|BDB_INDEX,
88                 bdb_cf_gen, "( OLcfgDbAt:0.2 NAME 'olcDbIndex' "
89                 "DESC 'Attribute index parameters' "
90                 "EQUALITY caseIgnoreMatch "
91                 "SYNTAX OMsDirectoryString )", NULL, NULL },
92         { "linearindex", NULL, 1, 2, 0, ARG_ON_OFF|ARG_OFFSET,
93                 (void *)offsetof(struct bdb_info, bi_linear_index), 
94                 "( OLcfgDbAt:1.7 NAME 'olcDbLinearIndex' "
95                 "DESC 'Index attributes one at a time' "
96                 "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
97         { "lockdetect", "policy", 2, 2, 0, ARG_MAGIC|BDB_LOCKD,
98                 bdb_cf_gen, "( OLcfgDbAt:1.8 NAME 'olcDbLockDetect' "
99                 "DESC 'Deadlock detection algorithm' "
100                 "SYNTAX OMsDirectoryString SINGLE-VALUE )", NULL, NULL },
101         { "mode", "mode", 2, 2, 0, ARG_INT|ARG_OFFSET,
102                 (void *)offsetof(struct bdb_info, bi_dbenv_mode),
103                 "( OLcfgDbAt:0.3 NAME 'olcDbMode' "
104                 "DESC 'Unix permissions of database files' "
105                 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
106         { "searchstack", "depth", 2, 2, 0, ARG_INT|ARG_MAGIC|BDB_SSTACK,
107                 bdb_cf_gen, "( OLcfgDbAt:1.9 NAME 'olcDbSearchStack' "
108                 "DESC 'Depth of search stack in IDLs' "
109                 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
110         { "shm_key", "key", 2, 2, 0, ARG_INT|ARG_OFFSET,
111                 (void *)offsetof(struct bdb_info, bi_shm_key), 
112                 "( OLcfgDbAt:1.10 NAME 'olcDbShmKey' "
113                 "DESC 'Key for shared memory region' "
114                 "SYNTAX OMsInteger SINGLE-VALUE )", NULL, NULL },
115         { NULL, NULL, 0, 0, 0, ARG_IGNORED,
116                 NULL, NULL, NULL, NULL }
117 };
118
119 static ConfigOCs bdbocs[] = {
120         { "( OLcfgDbOc:1.1 "
121                 "NAME 'olcBdbConfig' "
122                 "DESC 'BDB backend configuration' "
123                 "SUP olcDatabaseConfig "
124                 "MUST olcDbDirectory "
125                 "MAY ( olcDbCacheSize $ olcDbCheckpoint $ olcDbConfig $ "
126                 "olcDbNoSync $ olcDbDirtyRead $ olcDbIDLcacheSize $ "
127                 "olcDbIndex $ olcDbLinearIndex $ olcDbLockDetect $ "
128                 "olcDbMode $ olcDbSearchStack $ olcDbShmKey ) )",
129                         Cft_Database, &bdb_oc },
130         { NULL, 0, NULL }
131 };
132
133 static int
134 bdb_cf_oc(ConfigArgs *c)
135 {
136         if ( c->op == SLAP_CONFIG_EMIT ) {
137                 value_add_one( &c->rvalue_vals, &bdb_oc->soc_cname );
138                 return 0;
139         }
140         return 1;
141 }
142
143 static slap_verbmasks bdb_lockd[] = {
144         { BER_BVC("default"), DB_LOCK_DEFAULT },
145         { BER_BVC("oldest"), DB_LOCK_OLDEST },
146         { BER_BVC("random"), DB_LOCK_RANDOM },
147         { BER_BVC("youngest"), DB_LOCK_YOUNGEST },
148         { BER_BVC("fewest"), DB_LOCK_MINLOCKS },
149         { BER_BVNULL, 0 }
150 };
151
152 /* perform periodic checkpoints */
153 static void *
154 bdb_checkpoint( void *ctx, void *arg )
155 {
156         struct re_s *rtask = arg;
157         struct bdb_info *bdb = rtask->arg;
158         
159         TXN_CHECKPOINT( bdb->bi_dbenv, bdb->bi_txn_cp_kbyte,
160                 bdb->bi_txn_cp_min, 0 );
161         ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
162         ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
163         ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
164         return NULL;
165 }
166
167 /* reindex entries on the fly */
168 static void *
169 bdb_online_index( void *ctx, void *arg )
170 {
171         struct re_s *rtask = arg;
172         BackendDB *be = rtask->arg;
173         struct bdb_info *bdb = be->be_private;
174
175         Connection conn = {0};
176         char opbuf[OPERATION_BUFFER_SIZE];
177         Operation *op = (Operation *)opbuf;
178
179         DBC *curs;
180         DBT key, data;
181         DB_TXN *txn;
182         DB_LOCK lock;
183         u_int32_t locker;
184         ID id, nid;
185         EntryInfo *ei;
186         int rc, getnext = 1;
187
188         connection_fake_init( &conn, op, ctx );
189
190         op->o_bd = be;
191
192         DBTzero( &key );
193         DBTzero( &data );
194         
195         id = 1;
196         key.data = &nid;
197         key.size = key.ulen = sizeof(ID);
198         key.flags = DB_DBT_USERMEM;
199
200         data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
201         data.dlen = data.ulen = 0;
202
203         while ( 1 ) {
204                 if ( slapd_shutdown )
205                         break;
206
207                 rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &txn, bdb->bi_db_opflags );
208                 if ( rc ) 
209                         break;
210                 locker = TXN_ID( txn );
211                 if ( getnext ) {
212                         getnext = 0;
213                         BDB_ID2DISK( id, &nid );
214                         rc = bdb->bi_id2entry->bdi_db->cursor(
215                                 bdb->bi_id2entry->bdi_db, txn, &curs, bdb->bi_db_opflags );
216                         if ( rc ) {
217                                 TXN_ABORT( txn );
218                                 break;
219                         }
220                         rc = curs->c_get( curs, &key, &data, DB_SET_RANGE );
221                         curs->c_close( curs );
222                         if ( rc ) {
223                                 TXN_ABORT( txn );
224                                 if ( rc == DB_NOTFOUND )
225                                         rc = 0;
226                                 if ( rc == DB_LOCK_DEADLOCK ) {
227                                         ldap_pvt_thread_yield();
228                                         continue;
229                                 }
230                                 break;
231                         }
232                         BDB_DISK2ID( &nid, &id );
233                 }
234
235                 ei = NULL;
236                 rc = bdb_cache_find_id( op, txn, id, &ei, 0, locker, &lock );
237                 if ( rc ) {
238                         TXN_ABORT( txn );
239                         if ( rc == DB_LOCK_DEADLOCK ) {
240                                 ldap_pvt_thread_yield();
241                                 continue;
242                         }
243                         if ( rc == DB_NOTFOUND ) {
244                                 id++;
245                                 getnext = 1;
246                                 continue;
247                         }
248                         break;
249                 }
250                 if ( ei->bei_e ) {
251                         rc = bdb_index_entry( op, txn, BDB_INDEX_UPDATE_OP, ei->bei_e );
252                         if ( rc == DB_LOCK_DEADLOCK ) {
253                                 TXN_ABORT( txn );
254                                 ldap_pvt_thread_yield();
255                                 continue;
256                         }
257                         if ( rc == 0 ) {
258                                 rc = TXN_COMMIT( txn, 0 );
259                                 txn = NULL;
260                         }
261                         if ( rc )
262                                 break;
263                 }
264                 id++;
265                 getnext = 1;
266         }
267 out:
268         ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
269         ldap_pvt_runqueue_stoptask( &slapd_rq, rtask );
270         ldap_pvt_runqueue_remove( &slapd_rq, rtask );
271         ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
272
273         return NULL;
274 }
275
276 /* Cleanup loose ends after Modify completes */
277 static int
278 bdb_cf_cleanup( ConfigArgs *c )
279 {
280         struct bdb_info *bdb = c->be->be_private;
281
282         if ( bdb->bi_flags & BDB_UPD_CONFIG ) {
283                 if ( bdb->bi_db_config ) {
284                         int i;
285                         FILE *f = fopen( bdb->bi_db_config_path, "w" );
286                         if ( f ) {
287                                 for (i=0; bdb->bi_db_config[i].bv_val; i++)
288                                         fprintf( f, "%s\n", bdb->bi_db_config[i].bv_val );
289                                 fclose( f );
290                         }
291                 } else {
292                         unlink( bdb->bi_db_config_path );
293                 }
294                 bdb->bi_flags ^= BDB_UPD_CONFIG;
295         }
296
297         if ( bdb->bi_flags & BDB_DEL_INDEX ) {
298                 bdb_attr_flush( bdb );
299                 bdb->bi_flags ^= BDB_DEL_INDEX;
300         }
301
302         return 0;
303 }
304
305 static int
306 bdb_cf_gen(ConfigArgs *c)
307 {
308         struct bdb_info *bdb = c->be->be_private;
309         int rc;
310
311         if ( c->op == SLAP_CONFIG_EMIT ) {
312                 rc = 0;
313                 switch( c->type ) {
314                 case BDB_CHKPT:
315                         if (bdb->bi_txn_cp ) {
316                                 char buf[64];
317                                 struct berval bv;
318                                 bv.bv_len = sprintf( buf, "%d %d", bdb->bi_txn_cp_kbyte,
319                                         bdb->bi_txn_cp_min );
320                                 bv.bv_val = buf;
321                                 value_add_one( &c->rvalue_vals, &bv );
322                         } else{
323                                 rc = 1;
324                         }
325                         break;
326
327                 case BDB_DIRECTORY:
328                         if ( bdb->bi_dbenv_home ) {
329                                 c->value_string = ch_strdup( bdb->bi_dbenv_home );
330                         } else {
331                                 rc = 1;
332                         }
333                         break;
334
335                 case BDB_CONFIG:
336                         if ( bdb->bi_db_config ) {
337                                 int i;
338                                 struct berval bv;
339
340                                 bv.bv_val = c->log;
341                                 for (i=0; !BER_BVISNULL(&bdb->bi_db_config[i]); i++) {
342                                         bv.bv_len = sprintf( bv.bv_val, "{%d}%s", i,
343                                                 bdb->bi_db_config[i].bv_val );
344                                         value_add_one( &c->rvalue_vals, &bv );
345                                 }
346                         }
347                         if ( !c->rvalue_vals ) rc = 1;
348                         break;
349
350                 case BDB_NOSYNC:
351                         if ( bdb->bi_dbenv_xflags & DB_TXN_NOSYNC )
352                                 c->value_int = 1;
353                         break;
354                         
355                 case BDB_INDEX:
356                         bdb_attr_index_unparse( bdb, &c->rvalue_vals );
357                         if ( !c->rvalue_vals ) rc = 1;
358                         break;
359
360                 case BDB_LOCKD:
361                         rc = 1;
362                         if ( bdb->bi_lock_detect != DB_LOCK_DEFAULT ) {
363                                 int i;
364                                 for (i=0; !BER_BVISNULL(&bdb_lockd[i].word); i++) {
365                                         if ( bdb->bi_lock_detect == bdb_lockd[i].mask ) {
366                                                 value_add_one( &c->rvalue_vals, &bdb_lockd[i].word );
367                                                 rc = 0;
368                                                 break;
369                                         }
370                                 }
371                         }
372                         break;
373
374                 case BDB_SSTACK:
375                         c->value_int = bdb->bi_search_stack_depth;
376                         break;
377                 }
378                 return rc;
379         } else if ( c->op == LDAP_MOD_DELETE ) {
380                 rc = 0;
381                 switch( c->type ) {
382                 /* single-valued no-ops */
383                 case BDB_LOCKD:
384                 case BDB_SSTACK:
385                         break;
386
387                 case BDB_CHKPT:
388                         if ( bdb->bi_txn_cp_task ) {
389                                 struct re_s *re = bdb->bi_txn_cp_task;
390                                 bdb->bi_txn_cp_task = NULL;
391                                 if ( ldap_pvt_runqueue_isrunning( &slapd_rq, re ))
392                                         ldap_pvt_runqueue_stoptask( &slapd_rq, re );
393                                 ldap_pvt_runqueue_remove( &slapd_rq, re );
394                         }
395                         bdb->bi_txn_cp = 0;
396                         break;
397                 case BDB_CONFIG:
398                         if ( c->valx < 0 ) {
399                                 ber_bvarray_free( bdb->bi_db_config );
400                                 bdb->bi_db_config = NULL;
401                         } else {
402                                 int i = c->valx;
403                                 ch_free( bdb->bi_db_config[i].bv_val );
404                                 for (; bdb->bi_db_config[i].bv_val; i++)
405                                         bdb->bi_db_config[i] = bdb->bi_db_config[i+1];
406                         }
407                         bdb->bi_flags |= BDB_UPD_CONFIG;
408                         c->cleanup = bdb_cf_cleanup;
409                         break;
410                 case BDB_DIRECTORY:
411                         rc = 1;
412                         /* FIXME: what does this mean? */
413                         break;
414                 case BDB_NOSYNC:
415                         bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC, 0 );
416                         break;
417                 case BDB_INDEX: {
418                         AttributeDescription *ad = NULL;
419                         struct berval bv, def = BER_BVC("default");
420                         char *ptr;
421                         const char *text;
422                         for (ptr = c->line; !isspace( *ptr ); ptr++);
423                         bv.bv_val = c->line;
424                         bv.bv_len = ptr - bv.bv_val;
425                         if ( bvmatch( &bv, &def )) {
426                                 bdb->bi_defaultmask = 0;
427                         } else {
428                                 slap_bv2ad( &bv, &ad, &text );
429                                 if ( ad ) {
430                                         AttrInfo *ai = bdb_attr_mask( bdb, ad );
431                                         ai->ai_indexmask |= BDB_INDEX_DELETING;
432                                         bdb->bi_flags |= BDB_DEL_INDEX;
433                                         c->cleanup = bdb_cf_cleanup;
434                                 }
435                         }
436                         }
437                         break;
438                 }
439                 return rc;
440         }
441
442         switch( c->type ) {
443         case BDB_CHKPT:
444                 bdb->bi_txn_cp = 1;
445                 bdb->bi_txn_cp_kbyte = strtol( c->argv[1], NULL, 0 );
446                 bdb->bi_txn_cp_min = strtol( c->argv[2], NULL, 0 );
447                 /* If we're in server mode and time-based checkpointing is enabled,
448                  * submit a task to perform periodic checkpoints.
449                  */
450                 if ((slapMode & SLAP_SERVER_MODE) && bdb->bi_txn_cp_min ) {
451                         struct re_s *re = bdb->bi_txn_cp_task;
452                         if ( re )
453                                 re->interval.tv_sec = bdb->bi_txn_cp_min * 60;
454                         else
455                                 bdb->bi_txn_cp_task = ldap_pvt_runqueue_insert( &slapd_rq,
456                                         bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb );
457                 }
458                 break;
459
460         case BDB_CONFIG: {
461                 char *ptr = c->line + STRLENOF("dbconfig");
462                 struct berval bv;
463                 while (!isspace(*ptr)) ptr++;
464                 while (isspace(*ptr)) ptr++;
465                 
466                 if ( bdb->bi_flags & BDB_IS_OPEN ) {
467                         bdb->bi_flags |= BDB_UPD_CONFIG;
468                         c->cleanup = bdb_cf_cleanup;
469                 } else {
470                 /* If we're just starting up...
471                  */
472                         FILE *f;
473                         /* If a DB_CONFIG file exists, or we don't know the path
474                          * to the DB_CONFIG file, ignore these directives
475                          */
476                         if (( bdb->bi_flags & BDB_HAS_CONFIG ) || !bdb->bi_db_config_path )
477                                 break;
478                         f = fopen( bdb->bi_db_config_path, "a" );
479                         if ( f ) {
480                                 /* FIXME: EBCDIC probably needs special handling */
481                                 fprintf( f, "%s\n", ptr );
482                                 fclose( f );
483                         }
484                 }
485                 ber_str2bv( ptr, 0, 1, &bv );
486                 ber_bvarray_add( &bdb->bi_db_config, &bv );
487                 }
488                 break;
489
490         case BDB_DIRECTORY: {
491                 FILE *f;
492                 char *ptr;
493
494                 bdb->bi_dbenv_home = c->value_string;
495
496                 /* See if a DB_CONFIG file already exists here */
497                 bdb->bi_db_config_path = ch_malloc( strlen( bdb->bi_dbenv_home ) +
498                         STRLENOF(LDAP_DIRSEP) + STRLENOF("DB_CONFIG") + 1 );
499                 ptr = lutil_strcopy( bdb->bi_db_config_path, bdb->bi_dbenv_home );
500                 *ptr++ = LDAP_DIRSEP[0];
501                 strcpy( ptr, "DB_CONFIG" );
502
503                 f = fopen( bdb->bi_db_config_path, "r" );
504                 if ( f ) {
505                         bdb->bi_flags |= BDB_HAS_CONFIG;
506                         fclose(f);
507                 }
508                 }
509                 break;
510
511         case BDB_NOSYNC:
512                 if ( c->value_int )
513                         bdb->bi_dbenv_xflags |= DB_TXN_NOSYNC;
514                 else
515                         bdb->bi_dbenv_xflags &= ~DB_TXN_NOSYNC;
516                 if ( bdb->bi_flags & BDB_IS_OPEN ) {
517                         bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC,
518                                 c->value_int );
519                 }
520                 break;
521
522         case BDB_INDEX:
523                 rc = bdb_attr_index_config( bdb, c->fname, c->lineno,
524                         c->argc - 1, &c->argv[1] );
525
526                 if( rc != LDAP_SUCCESS ) return 1;
527                 if ( bdb->bi_flags & BDB_IS_OPEN ) {
528                         /* Start the task as soon as we finish here */
529                         ldap_pvt_runqueue_insert( &slapd_rq, 60,
530                                 bdb_online_index, c->be );
531                 }
532                 break;
533
534         case BDB_LOCKD:
535                 rc = verb_to_mask( c->argv[1], bdb_lockd );
536                 if ( BER_BVISNULL(&bdb_lockd[rc].word) ) {
537                         fprintf( stderr, "%s: "
538                                 "bad policy (%s) in \"lockDetect <policy>\" line\n",
539                                 c->log, c->argv[1] );
540                         return 1;
541                 }
542                 bdb->bi_lock_detect = rc;
543                 break;
544
545         case BDB_SSTACK:
546                 if ( c->value_int < MINIMUM_SEARCH_STACK_DEPTH ) {
547                         fprintf( stderr,
548                 "%s: depth %d too small, using %d\n",
549                         c->log, c->value_int, MINIMUM_SEARCH_STACK_DEPTH );
550                         c->value_int = MINIMUM_SEARCH_STACK_DEPTH;
551                 }
552                 bdb->bi_search_stack_depth = c->value_int;
553                 break;
554         }
555         return 0;
556 }
557
558 int bdb_back_init_cf( BackendInfo *bi )
559 {
560         int rc;
561         bi->bi_cf_table = bdbcfg;
562
563         rc = config_register_schema( bdbcfg, bdbocs );
564         if ( rc ) return rc;
565         bdbcfg[0].ad = slap_schema.si_ad_objectClass;
566         return 0;
567 }