]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/config.c
Fix aci link error.
[openldap] / servers / slapd / back-ldap / config.c
1 /* config.c - ldap backend configuration file routine */
2 /* $OpenLDAP$ */
3
4 /*
5  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
6  * 
7  * Permission is granted to anyone to use this software for any purpose
8  * on any computer system, and to alter it and redistribute it, subject
9  * to the following restrictions:
10  * 
11  * 1. The author is not responsible for the consequences of use of this
12  *    software, no matter how awful, even if they arise from flaws in it.
13  * 
14  * 2. The origin of this software must not be misrepresented, either by
15  *    explicit claim or by omission.  Since few users ever read sources,
16  *    credits should appear in the documentation.
17  * 
18  * 3. Altered versions must be plainly marked as such, and must not be
19  *    misrepresented as being the original software.  Since few users
20  *    ever read sources, credits should appear in the documentation.
21  * 
22  * 4. This notice may not be removed or altered.
23  */
24
25 #include "portable.h"
26
27 #include <stdio.h>
28
29 #include <ac/string.h>
30 #include <ac/socket.h>
31
32 #include "slap.h"
33 #include "back-ldap.h"
34
35 int
36 ldap_back_db_config(
37     BackendDB   *be,
38     const char  *fname,
39     int         lineno,
40     int         argc,
41     char        **argv
42 )
43 {
44         struct ldapinfo *li = (struct ldapinfo *) be->be_private;
45
46         if ( li == NULL ) {
47                 fprintf( stderr, "%s: line %d: ldap backend info is null!\n",
48                     fname, lineno );
49                 return( 1 );
50         }
51
52         /* server address to query (depricated, use "uri" directive) */
53         if ( strcasecmp( argv[0], "server" ) == 0 ) {
54                 if (argc != 2) {
55                         fprintf( stderr,
56         "%s: line %d: missing address in \"server <address>\" line\n",
57                             fname, lineno );
58                         return( 1 );
59                 }
60                 if (li->url != NULL)
61                         ch_free(li->url);
62                 li->url = ch_calloc(strlen(argv[1]) + 9, sizeof(char));
63                 if (li->url != NULL) {
64                         strcpy(li->url, "ldap://");
65                         strcat(li->url, argv[1]);
66                         strcat(li->url, "/");
67                 }
68
69         /* URI of server to query (preferred over "server" directive) */
70         } else if ( strcasecmp( argv[0], "uri" ) == 0 ) {
71                 if (argc != 2) {
72                         fprintf( stderr,
73         "%s: line %d: missing address in \"uri <address>\" line\n",
74                             fname, lineno );
75                         return( 1 );
76                 }
77                 if (li->url != NULL)
78                         ch_free(li->url);
79                 li->url = ch_strdup(argv[1]);
80
81         /* name to use for ldap_back_group */
82         } else if ( strcasecmp( argv[0], "binddn" ) == 0 ) {
83                 if (argc != 2) {
84                         fprintf( stderr,
85         "%s: line %d: missing name in \"binddn <name>\" line\n",
86                             fname, lineno );
87                         return( 1 );
88                 }
89                 li->binddn = ch_strdup(argv[1]);
90
91         /* password to use for ldap_back_group */
92         } else if ( strcasecmp( argv[0], "bindpw" ) == 0 ) {
93                 if (argc != 2) {
94                         fprintf( stderr,
95         "%s: line %d: missing password in \"bindpw <password>\" line\n",
96                             fname, lineno );
97                         return( 1 );
98                 }
99                 li->bindpw = ch_strdup(argv[1]);
100
101         /* anything else */
102         } else {
103                 fprintf( stderr,
104 "%s: line %d: unknown directive \"%s\" in ldap database definition (ignored)\n",
105                     fname, lineno, argv[0] );
106         }
107         return 0;
108 }