static int
connect_to_x500( void )
{
- if ( (ld = ldap_open( LDAPHOST, LDAP_PORT )) == NULL ) {
+ if ( (ld = ldap_open( NULL, 0 )) == NULL ) {
syslog( LOG_ALERT, "ldap_open failed" );
return( -1 );
}
ld->ld_sizelimit = FAX_MAXAMBIGUOUS;
ld->ld_deref = LDAP_DEREF_ALWAYS;
- if ( ldap_simple_bind_s( ld, FAX_BINDDN, FAX_BIND_CRED ) != LDAP_SUCCESS ) {
+ if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
syslog( LOG_ALERT, "ldap_simple_bind_s failed" );
return( -1 );
}
#define DEFAULT_SIZELIMIT 50
int debug;
-char *ldaphost = LDAPHOST;
-char *base = RP_BASE;
+char *ldaphost = NULL;
+char *base = NULL;
int deref;
int sizelimit;
LDAPFiltDesc *filtd;
exit( -1 );
}
- if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+ if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
perror( "ldap_open" );
exit( -1 );
}
ld->ld_sizelimit = sizelimit ? sizelimit : DEFAULT_SIZELIMIT;
ld->ld_deref = deref;
- if ( ldap_simple_bind_s( ld, RP_BINDDN, RP_BIND_CRED ) != LDAP_SUCCESS ) {
+ if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
fprintf( stderr, "X.500 is temporarily unavailable.\n" );
ldap_perror( ld, "ldap_simple_bind_s" );
exit( -1 );
int dosyslog = 1;
-char *ldaphost = LDAPHOST;
-int ldapport = LDAP_PORT;
-char *base = FINGER_BASE;
+char *ldaphost = NULL;
+int ldapport = 0;
+char *base = NULL;
int deref;
char *filterfile = FILTERFILE;
char *templatefile = TEMPLATEFILE;
ld->ld_sizelimit = FINGER_SIZELIMIT;
ld->ld_deref = deref;
- if ( ldap_simple_bind_s( ld, FINGER_BINDDN, FINGER_BIND_CRED )
+ if ( ldap_simple_bind_s( ld, NULL, NULL )
!= LDAP_SUCCESS )
{
fprintf( stderr, FINGER_UNAVAILABLE );
int inetd;
int dtblsize;
-char *ldaphost = LDAPHOST;
-char *base = GO500_BASE;
+char *ldaphost = NULL;
+char *base = NULL;
int rdncount = GO500_RDNCOUNT;
char *filterfile = FILTERFILE;
char *templatefile = TEMPLATEFILE;
if ( *query == '~' || *query == '@' ) {
ld = NULL;
} else {
- if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+ if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
fprintf(fp,
"0An error occurred (explanation)\t@%d\t%s\t%d\r\n",
LDAP_SERVER_DOWN, myhost, myport );
}
ld->ld_deref = GO500_DEREF;
- if ( (rc = ldap_simple_bind_s( ld, GO500_BINDDN, GO500_BIND_CRED ))
+ if ( (rc = ldap_simple_bind_s( ld, NULL, NULL ))
!= LDAP_SUCCESS ) {
fprintf(fp,
"0An error occurred (explanation)\t@%d\t%s\t%d\r\n",
int inetd;
int dtblsize;
-char *ldaphost = LDAPHOST;
-int ldapport = LDAP_PORT;
+char *ldaphost = NULL;
+int ldapport = 0;
int searchaliases = 1;
char *helpfile = GO500GW_HELPFILE;
char *filterfile = FILTERFILE;
if ( !searchaliases )
ld->ld_deref = LDAP_DEREF_FINDING;
- if ( (rc = ldap_simple_bind_s( ld, GO500GW_BINDDN, NULL ))
+ if ( (rc = ldap_simple_bind_s( ld, NULL, NULL ))
!= LDAP_SUCCESS ) {
if ( debug ) ldap_perror( ld, "ldap_simple_bind_s" );
fprintf(fp, "0An error occurred (explanation)\tE%d\t%s\t%d\r\n",
char *errorsfrom = NULL;
char *mailfrom = NULL;
char *host = NULL;
-char *ldaphost = LDAPHOST;
+char *ldaphost = NULL;
int hostlen = 0;
int debug;
static int
connect_to_x500( void )
{
- if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+ if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
syslog( LOG_ALERT, "ldap_open failed" );
return( -1 );
}
ld->ld_sizelimit = MAIL500_MAXAMBIGUOUS;
ld->ld_deref = LDAP_DEREF_ALWAYS;
- if ( ldap_simple_bind_s( ld, MAIL500_BINDDN, NULL ) != LDAP_SUCCESS ) {
+ if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
syslog( LOG_ALERT, "ldap_simple_bind_s failed" );
return( -1 );
}
int sizelimit = RCPT500_SIZELIMIT;
int rdncount = RCPT500_RDNCOUNT;
int ldapport = 0;
-char *ldaphost = LDAPHOST;
-char *searchbase = RCPT500_BASE;
-char *dapuser = RCPT500_BINDDN;
+char *ldaphost = NULL;
+char *searchbase = NULL;
+char *dapuser = NULL;
char *filterfile = FILTERFILE;
char *templatefile = TEMPLATEFILE;
static char reply[ MAXSIZE * RCPT500_LISTLIMIT ];
#include "ldapconfig.h"
-static char *binddn = LDAPDELETE_BINDDN;
-static char *passwd = LDAPDELETE_BIND_CRED;
-static char *base = LDAPDELETE_BASE;
-static char *ldaphost = LDAPHOST;
-static int ldapport = LDAP_PORT;
+static char *binddn = NULL;
+static char *passwd = NULL;
+static char *base = NULL;
+static char *ldaphost = NULL;
+static int ldapport = 0;
static int not, verbose, contoper;
static LDAP *ld;
#include "ldapconfig.h"
static char *prog;
-static char *binddn = LDAPMODIFY_BINDDN;
-static char *passwd = LDAPMODIFY_BIND_CRED;
-static char *ldaphost = LDAPHOST;
-static int ldapport = LDAP_PORT;
+static char *binddn = NULL;
+static char *passwd = NULL;
+static char *ldaphost = NULL;
+static int ldapport = 0;
static int new, replace, not, verbose, contoper, force, valsfromfiles;
static LDAP *ld;
if ( !use_record && strcasecmp( type, T_REPLICA_STR ) == 0 ) {
++saw_replica;
if (( p = strchr( value, ':' )) == NULL ) {
- replicaport = LDAP_PORT;
+ replicaport = 0;
} else {
*p++ = '\0';
replicaport = atoi( p );
#include "ldapconfig.h"
-static char *binddn = LDAPMODRDN_BINDDN;
-static char *passwd = LDAPMODRDN_BIND_CRED;
-static char *base = LDAPMODRDN_BASE;
-static char *ldaphost = LDAPHOST;
-static int ldapport = LDAP_PORT;
+static char *binddn = NULL;
+static char *passwd = NULL;
+static char *base = NULL;
+static char *ldaphost = NULL;
+static int ldapport = 0;
static int not, verbose, contoper;
static LDAP *ld;
char *filtpatt,
char *value));
-static char *binddn = LDAPSEARCH_BINDDN;
-static char *passwd = LDAPSEARCH_BIND_CRED;
-static char *base = LDAPSEARCH_BASE;
-static char *ldaphost = LDAPHOST;
-static int ldapport = LDAP_PORT;
+static char *binddn = NULL;
+static char *passwd = NULL;
+static char *base = NULL;
+static char *ldaphost = NULL;
+static int ldapport = 0;
static char *sep = DEFSEP;
static char *sortattr = NULL;
static int skipsortattr = 0;
else
ldap_perror(ld, "ldap_bind_s" );
(void) ldap_bind_s(ld, default_bind_object,
- (char *) UD_BIND_CRED, LDAP_AUTH_SIMPLE);
+ (char *) NULL, LDAP_AUTH_SIMPLE);
if (default_bind_object == NULL)
set_bound_dn(NULL);
else
static char *server = NULL;
static char *config_file = UD_CONFIG_FILE;
static char *filter_file = FILTERFILE;
-static int ldap_port = LDAP_PORT;
+static int ldap_port = 0;
static int dereference = TRUE;
-char *default_bind_object = UD_BINDDN;
+char *default_bind_object = NULL;
char *bound_dn; /* bound user's Distinguished Name */
char *group_base; /* place in LDAP tree where groups are */
/* set the search base back to the original default value */
else if (!strcasecmp(s, "default")) {
if (type == BASE_SEARCH)
- StrFreeDup(base, UD_BASE);
+ StrFreeDup(base, NULL);
else if (type == BASE_GROUPS)
StrFreeDup(base, UD_WHERE_GROUPS_ARE_CREATED);
printbase(output_string, *base);
continue;
server = strdup(cp);
}
+ else if (!strncasecmp(buffer, "host", 4)) {
+ if (server != NULL)
+ continue;
+ cp = buffer + 4;
+ while (isspace(*cp))
+ cp++;
+ if ((*cp == '\0') || (*cp == '\n'))
+ continue;
+ server = strdup(cp);
+ }
else if (!strncasecmp(buffer, "base", 4)) {
cp = buffer + 4;
while (isspace(*cp))
}
if (group_base == NULL)
group_base = strdup(UD_WHERE_GROUPS_ARE_CREATED);
- if (search_base == NULL)
- search_base = strdup(UD_BASE);
- if (server == NULL)
- server = strdup(LDAPHOST);
/*
* Set up our LDAP connection. The values of retry and timeout
exit(0);
/* NOTREACHED */
}
- if (ldap_bind_s(ld, (char *) default_bind_object, (char *) UD_BIND_CRED,
+ if (ldap_bind_s(ld, (char *) default_bind_object, (char *) NULL,
LDAP_AUTH_SIMPLE) != LDAP_SUCCESS) {
fprintf(stderr, " The LDAP Directory is temporarily unavailable. Please try again later.\n");
if (ld->ld_errno != LDAP_UNAVAILABLE)
char *
mygetpass( char *prompt )
{
-#if !defined(HAVE_TERMIOS) && !defined(HAVE_SGTTY_H)
+#if !defined(HAVE_POSIX_TERMIOS) && !defined(HAVE_SGTTY_H)
static char buf[256];
int i, c;
register char **cpp;
static char short_DN[BUFSIZ];
- if (strstr(s, UD_BASE) == NULL)
+ if (strstr(s, NULL) == NULL)
return(ldap_dn2ufn(s));
cpp = ldap_explode_dn(s, TRUE);
sprintf(short_DN, "%s, %s", *cpp, *(cpp + 1));
-.TH LDAPDELETE 1 "13 November 1995" "U-M LDAP LDVERSION"
+.TH LDAPDELETE 1 "10 November 1998" "OpenLDAP LDVERSION"
.SH NAME
ldapdelete \- ldap delete entry tool
.SH SYNOPSIS
replaced with a line from \fIfile\fP.
.TP
.B \-D binddn
-Use \fIbinddn\fP to bind to the X.500 directory. \fIbinddn\fP should be
+Use \fIbinddn\fP to bind to the LDAP directory. \fIbinddn\fP should be
a string-represented DN as defined in RFC 1779.
.TP
.B \-w passwd
Exit status is 0 if no errors occur. Errors result in a non-zero exit
status and a diagnostic message being written to standard error.
.SH "SEE ALSO"
+.BR ldap.conf (5),
.BR ldapadd (1),
.BR ldapmodify (1),
.BR ldapmodrdn (1),
ISODE Consortium, March 1995.
.SH BUGS
There is no interactive mode, but there probably should be.
+.SH ACKNOWLEDGEMENTS
+.B OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.
-.TH LDAPMODIFY 1 "13 November 1995" "U-M LDAP LDVERSION"
+.TH LDAPMODIFY 1 "10 November 1998" "OpenLDAP LDVERSION"
.SH NAME
ldapmodify, ldapadd \- ldap modify entry and ldap add entry tools
.SH SYNOPSIS
standard input.
.TP
.B \-D binddn
-Use \fIbinddn\fP to bind to the X.500 directory. \fIbinddn\fP should be
+Use \fIbinddn\fP to bind to the LDAP directory. \fIbinddn\fP should be
a string-represented DN as defined in RFC 1779.
.TP
.B \-w passwd
.BR ldapdelete (1),
.BR ldapmodrdn (1),
.BR ldapsearch (1),
+.BR ldap.conf (5),
.BR ldap (3),
.BR ldap_add (3),
.BR ldap_delete (3),
ISODE Consortium, March 1995.
.SH BUGS
There is no interactive mode, but there probably should be.
+.SH ACKNOWLEDGEMENTS
+.B OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.
-.TH LDAPMODRDN 1 "13 November 1995" "U-M LDAP LDVERSION"
+.TH LDAPMODRDN 1 "10 November 1998" "OpenLDAP LDVERSION"
.SH NAME
ldapmodrdn \- ldap modify entry RDN tool
.SH SYNOPSIS
standard input or the command-line.
.TP
.B \-D binddn
-Use \fIbinddn\fP to bind to the X.500 directory. \fIbinddn\fP should be
+Use \fIbinddn\fP to bind to the LDAP directory. \fIbinddn\fP should be
a string-represented DN as defined in RFC 1779.
.TP
.B \-w passwd
.BR ldapdelete (1),
.BR ldapmodify (1),
.BR ldapsearch (1),
+.BR ldap.conf (5),
.BR ldap (3),
.BR ldap_modrdn2 (3)
.LP
ISODE Consortium, March 1995.
.SH BUGS
There is no interactive mode, but there probably should be.
+.SH ACKNOWLEDGEMENTS
+.B OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.
-.TH LDAPSEARCH 1 "22 September 1998" "OpenLDAP LDVERSION"
+.TH LDAPSEARCH 1 "10 November 1998" "OpenLDAP LDVERSION"
.SH NAME
ldapsearch \- ldap search tool
.SH SYNOPSIS
character, then the lines are read from standard input.
.TP
.B \-D binddn
-Use \fIbinddn\fP to bind to the X.500 directory. \fIbinddn\fP should be
+Use \fIbinddn\fP to bind to the LDAP directory. \fIbinddn\fP should be
a string-represented DN as defined in RFC 1779.
.TP
.B \-w bindpasswd
.BR ldapdelete (1),
.BR ldapmodify (1),
.BR ldapmodrdn (1),
+.BR ldap.conf (5),
.BR ldap (3),
.BR ldap_search (3)
.LP
-.TH UD 1 "18 March 1993" "U-M LDAP LDVERSION"
+.TH UD 1 "10 November 1998" "OpenLDAP LDVERSION"
.UC 6
.SH NAME
-ud \- interactive X.500 Directory Server query program
+ud \- interactive LDAP Directory Server query program
.SH SYNOPSIS
.B ud
[-Dv] [-s
ETCDIR/ud.conf The ud configuration file.
.SH "SEE ALSO"
.BR ud.conf (5),
+.BR ldap.conf (5),
.BR ldap (3)
.SH DIAGNOSTICS
.B ud
Too numerous to mention.
.SH AUTHOR
Bryan Beecher, University of Michigan
+.SH ACKNOWLEDGEMENTS
+.B OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.
--- /dev/null
+.TH LDAP.CONF 5 "29 November 1998" "OpenLDAP LDVERSION"
+.UC 6
+.SH NAME
+ldap.conf \- ldap configuration file
+.SH SYNOPSIS
+ETCDIR/ldap.conf
+.SH DESCRIPTION
+The
+.I ldap.conf
+configuration file is used to set system-wide defaults to be applied when
+running
+.I ldap
+clients.
+Note that each user may specify an optional configuration file,
+.IR .ldaprc ,
+in his/her home directory which will be used to override system-wide
+defaults file. The user may also provide a local configuration
+file
+.I ldaprc
+which will be used to override per-user and system-wide defaults.
+Environmental variables may be used to file based defaults.
+.SH OPTIONS
+The different configuration options are:
+.TP 1i
+.TP 1i
+\fBBASE <base>\fP
+Used to specify the default base dn to use when performing ldap operations.
+The base must be specified as a Distinguished Name in LDAP format.
+\fBHOST <name[:port] ...>\fP
+Used to specify the name(s) of an LDAP server(s) to which
+.I ldap
+library should connect to. Each server's name can be specified as a
+domain-style name or an IP address and optionally followed a ':' and
+the port number the ldap server is listening on. A space separated
+listed of host may be provided.
+.TP 1i
+\fBPORT <port>\fP
+Used to specify the port used with connecting to LDAP servers(s).
+The port may be specified as a number.
+.TP 1i
+\fBSIZELIMIT <integer>\fP
+Used to specify a size limit to use when performing searches. The
+number should be an non-negative integer. \fISIZELIMIT\fP of zero (0)
+specifies unlimited search size.
+.TP 1i
+\fBTIMELIMIT <integer>\fP
+Used to specify a time limit to use when performing searches. The
+number should be an non-negative integer. \fITIMELIMIT\fP of zero (0)
+specifies unlimited search time to be used.
+.TP 1i
+\fBDEREF <never|searching|finding|always>\fP
+Specify how aliases dereferencing is done. \fIDEREF\fP should
+be set to one of
+.B never,
+.B always,
+.B search,
+or
+.B find
+to specify that aliases are never dereferenced, always dereferenced,
+dereferenced when searching, or dereferenced only when locating the
+base object for the search. The default is to never dereference aliases.
+.SH FILES
+.I ETCDIR/ldap.conf
+.SH "SEE ALSO"
+ldap(3)
+.SH AUTHOR
+Kurt Zeilenga, The OpenLDAP Project
+.SH ACKNOWLEDGEMENTS
+.B OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.
-.TH UD.CONF 5 "18 March 1993" "U-M LDAP LDVERSION"
+.TH UD.CONF 5 "22 September 1998" "OpenLDAP LDVERSION"
.UC 6
.SH NAME
ud.conf \- ud configuration file
.SH SYNOPSIS
-/etc/ud.conf
+ETCDIR/ud.conf
.SH DESCRIPTION
The
.I ud
.SH OPTIONS
The different configuration options are:
.TP 1i
-\fBserver <name>\fP
+\fBHOST <name>\fP
Used to specify the name of an LDAP server to which
.I ud
should connect. There may be only one entry per config file.
The server's name can be specified as a domain-style name or an IP address.
.TP 1i
-\fBbase <base>\fP
+\fBBASE <base>\fP
Used to specify the search base to use when performing search operations.
The base may be changed by those using
.I ud
There may be only one entry per config file.
The base must be specified as a Distinguished Name in LDAP format.
.TP 1i
-\fBgroupbase <base>\fP
+\fBGROUPBASE <base>\fP
Used to specify the base used when creating groups.
The base may be changed by those using
.I ud
There may be only one entry per config file.
The base must be specified as a Distinguished Name in LDAP format.
.TP 1i
-\fBsearch <algorithm>\fP
+\fBSEARCH <algorithm>\fP
Used to specify a search algorithm to use when performing searches. More than
one algorithm may be specified, and each is tried in turn until a suitable
response is found.
causes this algorithm to be applied when the number of fields is exactly equal
to one. If there is exactly one field, the token is looked up as a UID.
.SH FILES
-.I /etc/ud.conf
+.I ETCDIR/ud.conf
.SH "SEE ALSO"
ud(1),
ldap(3)
.SH AUTHOR
Bryan Beecher, University of Michigan
+.SH ACKNOWLEDGEMENTS
+.B OpenLDAP
+is developed and maintained by The OpenLDAP Project (http://www.openldap.org/).
+.B OpenLDAP
+is derived from University of Michigan LDAP 3.3 Release.
#define DEFAULT_SYSCONFDIR "%SYSCONFDIR%"
#define DEFAULT_LIBEXECDIR "%LIBEXECDIR%"
-/* default ldap host */
-#define LDAPHOST "localhost"
+#define DEFAULT_LDAP_CONF_FILE "%SYSCONFDIR%/ldap.conf"
+#define DEFAULT_LDAP_USERRC_FILE "ldaprc"
+#define DEFAULT_LDAP_ENV_PREFIX "LDAP"
-#define DEFAULT_LDAPHOST_FILE "%SYSCONFDIR%/ldaphost"
-/* default place to start searching */
-#define DEFAULT_BASE "o=Your Organization Name, c=US"
-#define DEFAULT_BASE_FILE "%SYSCONFDIR%/ldapbase"
-
-/*
- * default binddn and creditials
- * use files, make sure they are not generally readable
- */
-#define DEFAULT_BINDDN NULL
-#define DEFAULT_BINDDN_FILE "%SYSCONFDIR%/ldapbinddn"
-
-#define DEFAULT_BIND_CRED NULL
-#define DEFAULT_BIND_CRED_FILE "%SYSCONFDIR%/ldapbindcred"
/*********************************************************************
* *
/*
* FINGER DEFINITIONS
*/
- /* who to bind as */
-#define FINGER_BINDDN NULL
-#define FINGER_BIND_CRED NULL
- /* where to search */
-#define FINGER_BASE DEFAULT_BASE
/* banner to print */
-#define FINGER_BANNER "X.500 Finger Service...\r\n"
+#define FINGER_BANNER "OpenLDAP Finger Service...\r\n"
/* who to report errors to */
#define FINGER_ERRORS "System Administrator"
/* what to say if no matches are found */
/*
* GO500 GOPHER GATEWAY DEFINITIONS
*/
- /* who to bind as */
-#define GO500_BINDDN NULL
-#define GO500_BIND_CRED NULL
- /* where to search */
-#define GO500_BASE DEFAULT_BASE
/* port on which to listen */
#define GO500_PORT 5555
/* how to handle aliases */
/*
* GO500GW GOPHER GATEWAY DEFINITIONS
*/
- /* who to bind as */
-#define GO500GW_BINDDN NULL
-#define GO500GW_BIND_CRED NULL
/* where the helpfile lives */
#define GO500GW_HELPFILE "%DATADIR%/go500gw.help"
/* port on which to listen */
/*
* RCPT500 MAIL RESPONDER GATEWAY DEFINITIONS
*/
- /* who to bind as */
-#define RCPT500_BINDDN NULL
-#define RCPT500_BIND_CRED NULL
/* where the helpfile lives */
#define RCPT500_HELPFILE "%DATADIR%/rcpt500.help"
/* maximum number of matches returned */
/* command that will accept an RFC822 message text on standard
input, and send it. sendmail -t does this nicely. */
#define RCPT500_PIPEMAILCMD "%SENDMAIL% -t"
- /* where to search */
-#define RCPT500_BASE DEFAULT_BASE
/* attribute to use when sorting results */
#define RCPT500_SORT_ATTR SORT_ATTR
/* max number of hits displayed in full before a list is presented */
/* number of DN components to show in entry displays */
#define RCPT500_RDNCOUNT DEFAULT_RDNCOUNT
-/*
- * LDAPSEARCH TOOL
- */
- /* who to bind as */
-#define LDAPSEARCH_BINDDN NULL
-#define LDAPSEARCH_BIND_CRED NULL
- /* search base */
-#define LDAPSEARCH_BASE DEFAULT_BASE
-
-/*
- * LDAPMODIFY TOOL
- */
- /* who to bind as */
-#define LDAPMODIFY_BINDDN NULL
-#define LDAPMODIFY_BIND_CRED NULL
- /* search base */
-#define LDAPMODIFY_BASE DEFAULT_BASE
-
-/*
- * LDAPDELETE TOOL
- */
- /* who to bind as */
-#define LDAPDELETE_BINDDN NULL
-#define LDAPDELETE_BIND_CRED NULL
- /* search base */
-#define LDAPDELETE_BASE DEFAULT_BASE
-
-/*
- * LDAPMODRDN TOOL
- */
- /* who to bind as */
-#define LDAPMODRDN_BINDDN NULL
-#define LDAPMODRDN_BIND_CRED NULL
- /* search base */
-#define LDAPMODRDN_BASE DEFAULT_BASE
-
/*
* MAIL500 MAILER DEFINITIONS
*/
- /* who to bind as */
-#define MAIL500_BINDDN NULL
-#define MAIL500_BIND_CRED NULL
/* max number of ambiguous matches reported */
#define MAIL500_MAXAMBIGUOUS 10
/* max subscribers allowed (size limit when searching for them ) */
#define UD_DEFAULT_EDITOR "%EDITOR%"
/* default bbasename of user config file */
#define UD_USER_CONFIG_FILE ".udrc"
- /* default user to bind as */
-#define UD_BINDDN NULL
- /* default password to bind with */
-#define UD_BIND_CRED NULL
- /* default search base */
-#define UD_BASE DEFAULT_BASE
/* default base where groups are created */
#define UD_WHERE_GROUPS_ARE_CREATED ""
/* default base below which all groups live */
/*
* FAX500 DEFINITIONS
*/
- /* what to bind as */
-#define FAX_BINDDN NULL
-#define FAX_BIND_CRED NULL
- /* default search base */
-#define FAX_BASE DEFAULT_BASE
/* how long to wait for searches */
#define FAX_TIMEOUT 180
/* maximum number of ambiguous matches reported */
/*
* RP500 DEFINITIONS
*/
- /* what to bind as */
-#define RP_BINDDN NULL
-#define RP_BIND_CRED NULL
- /* default search base */
-#define RP_BASE DEFAULT_BASE
-
/* prefix to add to non-fully-qualified numbers */
#define RP_PHONEPREFIX ""
free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \
getdn.c getentry.c getattr.c getvalues.c addentry.c \
request.c getdxbyname.c os-ip.c url.c charset.c \
- strdup.c
+ init.c strdup.c
OBJS = bind.lo open.lo result.lo error.lo compare.lo search.lo \
modify.lo add.lo modrdn.lo delete.lo abandon.lo ufn.lo cache.lo \
getfilter.lo sbind.lo kbind.lo unbind.lo friendly.lo cldap.lo \
free.lo disptmpl.lo srchpref.lo dsparse.lo tmplout.lo sort.lo \
getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
request.lo getdxbyname.lo os-ip.lo url.lo charset.lo \
- strdup.lo
+ init.lo strdup.lo
LDAP_INCDIR= ../../include
LDAP_LIBDIR= ../../libraries
char *p;
int i;
+ if(!openldap_ldap_initialized) {
+ openldap_ldap_initialize();
+ }
+
Debug( LDAP_DEBUG_TRACE, "ldap_open\n", 0, 0, 0 );
if ( port == 0 ) {
- port = LDAP_PORT;
+ port = openldap_ldap_global_options.ldo_defport;
}
if ( (s = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) {
--- /dev/null
+#include "portable.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
+#include <ac/ctype.h>
+#include <ac/time.h>
+
+#include "lber.h"
+#include "ldap.h"
+
+#include "ldap-int.h"
+#include "ldapconfig.h"
+
+struct ldapoptions openldap_ldap_global_options;
+
+#undef gopts
+#define gopts openldap_ldap_global_options
+
+int openldap_ldap_initialized = 0;
+
+#define ATTR_NONE 0
+#define ATTR_BOOL 1
+#define ATTR_INT 2
+#define ATTR_KV 3
+#define ATTR_STRING 4
+
+struct ol_keyvalue {
+ char* key;
+ int value;
+};
+
+static struct ol_keyvalue deref_kv[] = {
+ {"never", LDAP_DEREF_NEVER},
+ {"searching", LDAP_DEREF_SEARCHING},
+ {"finding", LDAP_DEREF_FINDING},
+ {"always", LDAP_DEREF_ALWAYS},
+ {NULL, 0}
+};
+
+static struct ol_attribute {
+ int type;
+ char* name;
+ void* data;
+ size_t offset;
+} attrs[] = {
+ {ATTR_KV, "DEREF", deref_kv, /* or &deref_kv[0] */
+ offsetof(struct ldapoptions, ldo_deref)},
+ {ATTR_INT, "SIZELIMIT", NULL,
+ offsetof(struct ldapoptions, ldo_sizelimit)},
+ {ATTR_INT, "TIMELIMIT", NULL,
+ offsetof(struct ldapoptions, ldo_timelimit)},
+ {ATTR_STRING, "BASE", NULL,
+ offsetof(struct ldapoptions, ldo_defbase)},
+ {ATTR_STRING, "HOST", NULL,
+ offsetof(struct ldapoptions, ldo_defhost)},
+ {ATTR_INT, "PORT", NULL,
+ offsetof(struct ldapoptions, ldo_defport)},
+ {ATTR_NONE, NULL, NULL, 0}
+};
+
+#define MAX_LDAP_ATTR_LEN sizeof("SIZELIMIT")
+#define MAX_LDAP_ENV_PREFIX_LEN 8
+
+static void openldap_ldap_init_w_conf(const char *file)
+{
+ char linebuf[128];
+ FILE *fp;
+ int i;
+ char *cmd, *opt;
+ char *start, *end;
+
+ if (file == NULL) {
+ /* no file name */
+ return;
+ }
+
+ fp = fopen(file, "r");
+ if(fp == NULL) {
+ /* could not open file */
+ return;
+ }
+
+ while((start = fgets(linebuf, sizeof(linebuf), fp)) != NULL) {
+ /* skip lines starting with '#' */
+ if(*start == '#') continue;
+
+ /* trim leading white space */
+ while((*start != '\0') && isspace(*start)) start++;
+
+ /* anything left? */
+ if(*start == '\0') continue;
+
+ /* trim trailing white space */
+ end = &start[strlen(start)-1];
+ while(isspace(*end)) end--;
+ end[1] = '\0';
+
+ /* anything left? */
+ if(*start == '\0') continue;
+
+
+ /* parse the command */
+ cmd=start;
+ while((*start != '\0') && !isspace(*start)) {
+ start++;
+ }
+ if(*start == '\0') {
+ /* command has no argument */
+ continue;
+ }
+
+ *start++ = '\0';
+
+ /* we must have some non-whitespace to skip */
+ while(isspace(*start)) start++;
+ opt = start;
+
+ for(i=0; attrs[i].type != ATTR_NONE; i++) {
+ void *p;
+
+ if(strcasecmp(cmd, attrs[i].name) != 0) {
+ continue;
+ }
+
+ p = &((char *) &gopts)[attrs[i].offset];
+
+ switch(attrs[i].type) {
+ case ATTR_INT:
+ * (int*) p = atoi(opt);
+ break;
+
+ case ATTR_KV: {
+ struct ol_keyvalue *kv;
+
+ for(kv = (struct ol_keyvalue *) attrs[i].data;
+ kv->key != NULL;
+ kv++) {
+
+ if(strcasecmp(opt, kv->key) == 0) {
+ * (int*) p = kv->value;
+ break;
+ }
+ }
+ } break;
+
+ case ATTR_STRING:
+ if (* (char**) p != NULL) free(* (char**) p);
+ * (char**) p = ldap_strdup(opt);
+ break;
+ }
+ }
+ }
+}
+
+static void openldap_ldap_init_w_userconf(const char *file)
+{
+ char *home;
+ char *path;
+
+ if (file == NULL) {
+ /* no file name */
+ return;
+ }
+
+ home = getenv("HOME");
+
+ if (home != NULL) {
+ path = malloc(strlen(home) + strlen(file) + 3);
+ } else {
+ path = malloc(strlen(file) + 3);
+ }
+
+ if(home != NULL && path != NULL) {
+ /* we assume UNIX path syntax is used... */
+
+ /* try ~/file */
+ sprintf(path, "%s/%s", home, file);
+ openldap_ldap_init_w_conf(path);
+
+ /* try ~/.file */
+ sprintf(path, "%s/.%s", home, file);
+ openldap_ldap_init_w_conf(path);
+ }
+
+ if(path != NULL) {
+ free(path);
+ }
+
+ /* try file */
+ openldap_ldap_init_w_conf(file);
+}
+
+static void openldap_ldap_init_w_env(const char *prefix)
+{
+ char buf[MAX_LDAP_ATTR_LEN+MAX_LDAP_ENV_PREFIX_LEN];
+ int len;
+ int i;
+ void *p;
+ char *value;
+
+ if (prefix == NULL) {
+ prefix = DEFAULT_LDAP_ENV_PREFIX;
+ }
+
+ strncpy(buf, prefix, MAX_LDAP_ENV_PREFIX_LEN);
+ buf[MAX_LDAP_ENV_PREFIX_LEN] = '\0';
+ len = strlen(buf);
+
+ for(i=0; attrs[i].type != ATTR_NONE; i++) {
+ strcpy(&buf[len], attrs[i].name);
+ value = getenv(buf);
+
+ if(value == NULL) {
+ continue;
+ }
+
+ p = &((char *) &gopts)[attrs[i].offset];
+
+ switch(attrs[i].type) {
+ case ATTR_INT:
+ * (int*) p = atoi(value);
+ break;
+
+ case ATTR_KV: {
+ struct ol_keyvalue *kv;
+
+ for(kv = (struct ol_keyvalue *) attrs[i].data;
+ kv->key != NULL;
+ kv++) {
+
+ if(strcasecmp(value, kv->key) == 0) {
+ * (int*) p = kv->value;
+ break;
+ }
+ }
+ } break;
+
+ case ATTR_STRING:
+ if (* (char**) p != NULL) free(* (char**) p);
+ if (*value == '\0') {
+ * (char**) p = NULL;
+ } else {
+ * (char**) p = ldap_strdup(value);
+ }
+ break;
+ }
+ }
+}
+
+void openldap_ldap_initialize( void )
+{
+ if ( openldap_ldap_initialized ) {
+ return;
+ }
+
+ gopts.ldo_deref = LDAP_DEREF_NEVER;
+ gopts.ldo_timelimit = LDAP_NO_LIMIT;
+ gopts.ldo_sizelimit = LDAP_NO_LIMIT;
+
+ gopts.ldo_defhost = ldap_strdup("localhost");
+ gopts.ldo_defport = LDAP_PORT;
+
+ openldap_ldap_init_w_conf(DEFAULT_LDAP_CONF_FILE);
+ openldap_ldap_init_w_userconf(DEFAULT_LDAP_USERRC_FILE);
+
+ {
+ char *altfile = getenv("LDAPRC");
+
+ if( altfile != NULL ) {
+ openldap_ldap_init_w_conf( altfile );
+ }
+ }
+
+ openldap_ldap_init_w_env(NULL);
+
+ openldap_ldap_initialized = 1;
+}
#endif /* LDAP_DNS */
#endif /* LDAP_REFERRALS */
+/*
+ * structure representing get/set'able options
+ * which have global defaults.
+ */
+struct ldapoptions {
+ int ldo_deref;
+ int ldo_timelimit;
+ int ldo_sizelimit;
+
+ char* ldo_defbase;
+ char* ldo_defhost;
+ int ldo_defport;
+};
+
+extern struct ldapoptions openldap_ldap_global_options;
+extern int openldap_ldap_initialized;
+
+/* in init.c */
+void openldap_ldap_initialize LDAP_P(( void ));
+
/*
* in cache.c
*/
{
LDAP *ld;
+ if(!openldap_ldap_initialized) {
+ openldap_ldap_initialize();
+ }
+
Debug( LDAP_DEBUG_TRACE, "ldap_init\n", 0, 0, 0 );
#ifdef HAVE_WINSOCK2
}
- ld->ld_defport = ( defport == 0 ) ? LDAP_PORT : defport;
+ ld->ld_defport = ( defport == 0 ) ?
+ openldap_ldap_global_options.ldo_defport : defport;
ld->ld_version = LDAP_VERSION;
ld->ld_lberoptions = LBER_USE_DER;
ld->ld_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;
*ports++ = '\0';
srv->lsrv_port = atoi( ports );
} else {
- srv->lsrv_port = LDAP_PORT;
+ srv->lsrv_port = openldap_ldap_global_options.ldo_defport;
}
#ifdef LDAP_DNS
} else {
srvlist = NULL;
for ( i = 0; dxs[ i ] != NULL; ++i ) {
- port = LDAP_PORT;
+ port = openldap_global_ldap_options.ldo_defport;
server_dn = NULL;
if ( strchr( dxs[ i ], ':' ) == NULL ) {
host = dxs[ i ];
err = -1;
} else {
if ( ludp->lud_port == 0 ) {
- srv->lsrv_port = LDAP_PORT;
+ srv->lsrv_port = openldap_ldap_global_options.ldo_defport;
} else {
srv->lsrv_port = ludp->lud_port;
}
ldapsrcurl = NULL;
ldapdesturl = NULL;
- ldaphost = LDAPHOST;
- ldapbase = DEFAULT_BASE;
+ ldaphost = NULL;
+ ldapbase = NULL;
srcldapauthmethod = LDAP_AUTH_SIMPLE;
destldapauthmethod = LDAP_AUTH_SIMPLE;
srcldapbinddn = NULL;
fflush( stdout );
}
- if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+ if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
perror( "ldap_open" );
return( NULL );
}
free( ldapbase );
ldapbase = strdup( buf );
- if ( (ld = ldap_open( ldaphost, LDAP_PORT )) == NULL ) {
+ if ( (ld = ldap_open( ldaphost, 0 )) == NULL ) {
perror( "ldap_open" );
return( NULL );
}
ldap_debug = 255;
lber_debug = 255;
*/
- if ( (ld = ldap_open( "vertigo:5555", LDAP_PORT )) == NULL ) {
+ if ( (ld = ldap_open( "vertigo:5555", 0 )) == NULL ) {
perror( "ldap_open" );
exit( 1 );
}
ri->ri_port = atoi( hp );
}
if ( ri->ri_port <= 0 ) {
- ri->ri_port = LDAP_PORT;
+ ri->ri_port = 0;
}
ri->ri_hostname = strdup( val );
gots |= GOT_HOST;
if ( str_parse_line( line, &type, &value, &len ) < 0 ) {
return( NULL );
}
- port = LDAP_PORT;
+ port = 0;
if (( p = strchr( value, ':' )) != NULL ) {
*p = '\0';
p++;