Commit 9189f9e1 authored by Randy Kunkee's avatar Randy Kunkee
Browse files

Tcl package version 1.0 -> 1.1:

   Add timeout to control array.
   Add -lldap -llber when building shared library.
   Clean up pkgIndex.tcl creation and installation (should now support
   "package require" out of the box).
parent fc4fe0ec
Copyright (c) 1998-1999 NeoSoft, Inc.
For licensing information, see the file neoXldap.c and the COPYRIGHT
file contains in the directory you found this file.
For licensing information, see the file neoXldap.c and/or the COPYRIGHT
file contained in the directory you found this file.
This directory contains an extension to Tcl to interface with an
LDAP server. While this software is being released to the OpenLDAP
......@@ -10,7 +10,8 @@ be added) for other client libraries as well. As time goes on, it
is expected that code will converge rather than diverge.
Support is provided for University of Michigan LDAP version 3.3,
OpenLDAP, and Netscape.
OpenLDAP, and Netscape. The default configuration supports
OpenLDAP 1.2.4. OpenLDAP 2.x is not yet supported.
It uses GNU autoconf. It builds and installs without requiring
parallel directories, but it does require that Tcl and Extended Tcl
......@@ -21,8 +22,8 @@ For further info, try "./configure --help".
For example, I run:
./configure --prefix=/opt/neosoft97 --enable-shared \
./configure --prefix=/opt/neotcl --enable-shared \
Remember that --prefix must be the same prefix used when building
and installint Tcl.
......@@ -36,30 +37,24 @@ This module will install a regular shell (ldaptclsh) a windowing
shell (ldapwish) a library, a pkgIndex.tcl, and a manpage (ldap.n).
If your Tcl installation has been configured with --enable-shared,
then it is highly recommended that you also use --enable-shared
then you must also use --enable-shared here.
Shared libraries and Tcl packages.
If Tcl is built with --enable-shared, and OpenLDAP (or another version
If Tcl is built with --enable-shared, AND OpenLDAP (or another version
for that matter) has been build to create -llber and -lldap as shared
libaries, and you build ldaptcl with --enable-shared, it should be
libaries, AND you build ldaptcl with --enable-shared, it should be
possible to run a plain Tcl interpreter (eg. tclsh8.0) and do
package require Ldaptcl
which will install the "ldap" command into the interpreter.
This may require that you set the LD_LIBRARY_PATH environment variable
appropriately, or use -R or -W,-rpath ld command options.
It also may require that you modify the
If you configure with --enable-shared, and you have shared libraries
for -lldap and -llber, then you might be able to
"package require Ldaptcl", provided that everything is set up
exactly right, ie. -R ld flags, LD_LIBRARY_PATH environment variables,
You may need to set the LD_LIBRARY_PATH environment variable appropriately,
or use -R or -W,-rpath ld command options to resolve the search for ldap
and lber libraries.
This package was test built on a Sparc Solaris 2.5 using the SUN Pro C
This package was test built on a Alpha OSF4.0e with the native C
You may email comments or bug fixes to,
This diff is collapsed.
......@@ -2,11 +2,11 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tk installation
dnl to configure the system for the local environment.
# $Id:,v 1.15 1998/05/22 21:26:25 kunkee Exp $
# $Id:,v 1.1 1999/02/10 22:56:49 kunkee Exp $
if test "${prefix}" = "NONE"; then
......@@ -109,8 +109,8 @@ DL_LIBS=$TCL_DL_LIBS
# The statements below define a collection of symbols related to
......@@ -126,7 +126,7 @@ AC_ARG_ENABLE(shared,
if test "$ok" = "yes" -a "${SHLIB_SUFFIX}" != ""; then
......@@ -219,6 +219,10 @@ search criteria.
controlArray(attributes) is a list of attributes to be fetched.
If not specified, all attributes are fetched.
controlArray(timeout) a timeout value in seconds (may contain
fractional values -- extremely very small values are useful
for forcing timeout conditions to test timeouts).
For each matching record, destArray is populated with none,
some or all attribute-value pairs.
......@@ -241,7 +245,7 @@ To enable caching of data received from an LDAP connection,
foo cache enable timeout maxmem
...where timeout is specified in seconds, and maxmem is the
maximum memory to be used fo caching, in bytes.
maximum memory to be used for caching, in bytes.
If maxmem is 0, the cache size is restricted only by the timeout.
......@@ -23,7 +23,7 @@
* Requests for permission may be sent to NeoSoft Inc, 1770 St. James Place,
* Suite 500, Houston, TX, 77056.
* $Id: neoXldap.c,v 1.2 1999/04/29 22:14:57 hallvard Exp $
* $Id$
......@@ -37,11 +37,18 @@
* Current support is by Randy Kunkee.
* Add timeout to controlArray to set timeout for ldap_result.
* 4/14/99 - Randy
#include "tclExtend.h"
#include <lber.h>
#include <ldap.h>
#include <string.h>
#include <sys/time.h>
#include <math.h>
* Macros to do string compares. They pre-check the first character before
......@@ -58,8 +65,8 @@
* against the Netscape LDAP server and the much more reliable SDK,
* and then again backported to the Umich-3.3 client code.
#if defined(LDAP_API_VERSION)
#define OPEN_LDAP 1
#if defined(OPEN_LDAP)
/* LDAP_API_VERSION must be defined per the current draft spec
** it's value will be assigned RFC number. However, as
** no RFC is defined, it's value is currently implementation
......@@ -68,37 +75,26 @@
** This section is for OPENLDAP.
#define ldap_attributefree(p) ldap_memfree(p)
#define ldap_memfree(p) free(p)
#define LDAP_ERR_STRING(ld) \
#elif defined( LDAP_OPT_SIZELIMIT )
** Netscape SDK w/ ldap_set_option, ldap_get_option
#define ldap_attributefree(p) ldap_memfree(p)
#define LDAP_ERR_STRING(ld) \
ldap_err2string(ldap_get_lderrno(ld, (char**)NULL, (char**)NULL))
/* U-Mich/OpenLDAP 1.x API */
/* RFC-1823 w/ changes */
#define UMICH_LDAP
#define UMICH_LDAP 1
#define ldap_memfree(p) free(p)
#define ldap_ber_free(p, n) ber_free(p, n)
#define ldap_get_lderrno(ld, dummy1, dummy2) ((ld)->ld_errno)
#define ldap_value_free_len(bvals) ber_bvecfree(bvals)
#define ldap_attributefree(p)
#define LDAP_ERR_STRING(ld) \
#if defined(LDAP_API_VERSION)
static int ldap_get_lderrno(LDAP *ld)
int ld_errno = 0;
ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, (void*)&ld_errno);
return ld_errno;
......@@ -214,7 +210,7 @@ LDAP_ProcessOneSearchResult (interp, ldap, entry, destArrayNameObj, evalCodeObj)
static int
LDAP_PerformSearch (interp, ldap, base, scope, attrs, filtpatt, value, destArrayNameObj, evalCodeObj)
LDAP_PerformSearch (interp, ldap, base, scope, attrs, filtpatt, value, destArrayNameObj, evalCodeObj, timeout_p)
Tcl_Interp *interp;
LDAP *ldap;
char *base;
......@@ -224,6 +220,7 @@ LDAP_PerformSearch (interp, ldap, base, scope, attrs, filtpatt, value, destArray
char *value;
Tcl_Obj *destArrayNameObj;
Tcl_Obj *evalCodeObj;
struct timeval *timeout_p;
char filter[BUFSIZ];
int resultCode;
......@@ -253,7 +250,7 @@ LDAP_PerformSearch (interp, ldap, base, scope, attrs, filtpatt, value, destArray
while ((resultCode = ldap_result (ldap,
&resultMessage)) == LDAP_RES_SEARCH_ENTRY) {
entryMessage = ldap_first_entry(ldap, resultMessage);
......@@ -284,9 +281,13 @@ LDAP_PerformSearch (interp, ldap, base, scope, attrs, filtpatt, value, destArray
if (abandon) {
if (abandon || resultCode == 0) {
ldap_abandon(ldap, msgid);
if (resultCode == 0) {
Tcl_SetErrorCode (interp, "TIMEOUT", (char*) NULL);
Tcl_SetStringObj (resultObj, "LDAP timeout retrieving results", -1);
return TCL_ERROR;
} else {
if (resultCode == LDAP_RES_SEARCH_RESULT) {
if ((errorCode = ldap_result2error (ldap, resultMessage, 0))
......@@ -555,7 +556,7 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv)
return TCL_ERROR;
valPtrs = mod->mod_vals.modv_strvals =
valPtrs = mod->mod_vals.modv_strvals = \
(char **)ckalloc (sizeof (char *) * (valuesObjc + 1));
valPtrs[valuesObjc] = (char *)NULL;
......@@ -617,6 +618,10 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv)
char *filterPatternString;
char *timeoutString;
double timeoutTime;
struct timeval timeout, *timeout_p;
Tcl_Obj *destArrayNameObj;
Tcl_Obj *evalCodeObj;
......@@ -735,6 +740,24 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv)
/* Fetch timeout value if there is one
timeoutString = Tcl_GetVar2 (interp,
timeout.tv_usec = 0;
if (timeoutString == (char *)NULL) {
timeout_p = NULL;
timeout.tv_sec = 0;
} else {
if (Tcl_GetDouble(interp, timeoutString, &timeoutTime) != TCL_OK)
return TCL_ERROR;
timeout.tv_sec = floor(timeoutTime);
timeout.tv_usec = (timeoutTime-timeout.tv_sec) * 1000000;
timeout_p = &timeout;
ldap->ld_deref = deref;
ldap->ld_timelimit = 0;
......@@ -750,7 +773,8 @@ NeoX_LdapTargetObjCmd (clientData, interp, objc, objv)
package ifneeded Neo @NEO_VERSION@ "package require Tclx 8.0; load [file join $dir .. @NEO_SHARED_LIB_FILE@] Ldaptcl"
package ifneeded Ldaptcl @NEO_VERSION@ "load [file join $dir .. @NEO_SHARED_LIB_FILE@] Ldaptcl"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment