Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • openldap/openldap
  • hyc/openldap
  • ryan/openldap
  • iboukris/openldap
  • ondra/openldap
  • sshanks-kx/openldap
  • blaggacao/openldap
  • pbrezina/openldap
  • quanah/openldap
  • dragos_h/openldap
  • lorenz/openldap
  • tsaarni/openldap
  • fei.ding/openldap
  • orent/openldap
  • arrowplum/openldap
  • barchiesi/openldap
  • jotik/openldap
  • hamano/openldap
  • ingovoss/openldap
  • henson/openldap
  • jlrine2/openldap
  • howeverAT/openldap
  • nivanova/openldap
  • orbea/openldap
  • rdubner/openldap
  • smckinney/openldap
  • jklowden/openldap
  • dpa-openldap/openldap
  • rouzier/openldap
  • orgads/openldap
  • ffontaine/openldap
  • jiaqingz/openldap
  • dcoutadeur/openldap
  • begeragus/openldap
  • pubellit/openldap
  • glandium/openldap
  • facboy/openldap
  • thesamesam/openldap
  • Johan/openldap
  • fkooman/openldap
  • gburd/openldap
  • h-homma/openldap
  • sgallagher/openldap
  • ahmed_zaki/openldap
  • gnoe/openldap
  • mid/openldap
  • clan/openldap
47 results
Show changes
Showing
with 186 additions and 4863 deletions
......@@ -25,8 +25,8 @@ LDAPConnection::LDAPConnection(const string& hostname, int port,
LDAPConnection::~LDAPConnection(){
}
int LDAPConnection::start_tls(){
return LDAPAsynConnection::start_tls();
void LDAPConnection::start_tls(){
LDAPAsynConnection::start_tls();
}
void LDAPConnection::bind(const string& dn, const string& passwd,
......@@ -50,9 +50,10 @@ void LDAPConnection::bind(const string& dn, const string& passwd,
delete msg;
throw LDAPReferralException(urls);
}else{
string srvMsg = res->getErrMsg();
delete res;
delete msg;
throw LDAPException(resCode);
throw LDAPException(resCode, srvMsg);
}
}
delete res;
......@@ -97,9 +98,10 @@ bool LDAPConnection::compare(const string& dn, const LDAPAttribute& attr,
}
break;
default :
string srvMsg = res->getErrMsg();
delete res;
delete msg;
throw LDAPException(resCode);
throw LDAPException(resCode, srvMsg);
}
}
......@@ -130,9 +132,10 @@ void LDAPConnection::del(const string& dn, const LDAPConstraints* cons){
}
break;
default :
string srvMsg = res->getErrMsg();
delete res;
delete msg;
throw LDAPException(resCode);
throw LDAPException(resCode, srvMsg);
}
}
......@@ -164,9 +167,10 @@ void LDAPConnection::add(const LDAPEntry* le, const LDAPConstraints* cons){
}
break;
default :
string srvMsg = res->getErrMsg();
delete res;
delete msg;
throw LDAPException(resCode);
throw LDAPException(resCode, srvMsg);
}
}
......@@ -201,7 +205,7 @@ void LDAPConnection::modify(const string& dn, const LDAPModList* mods,
string srvMsg = res->getErrMsg();
delete res;
delete msg;
throw LDAPException(resCode,srvMsg);
throw LDAPException(resCode, srvMsg);
}
}
......@@ -236,9 +240,10 @@ void LDAPConnection::rename(const string& dn, const string& newRDN,
}
break;
default :
string srvMsg = res->getErrMsg();
delete res;
delete msg;
throw LDAPException(resCode);
throw LDAPException(resCode, srvMsg);
}
}
......@@ -278,10 +283,11 @@ LDAPSearchResults* LDAPConnection::search(const string& base, int scope,
}
break;
default :
string srvMsg = res->getErrMsg();
delete results; // memcheck
delete res;
delete msgq;
throw LDAPException(resCode);
throw LDAPException(resCode, srvMsg);
}
}
return 0;
......@@ -314,9 +320,10 @@ LDAPExtResult* LDAPConnection::extOperation(const string& oid,
}
break;
default :
string srvMsg = res->getErrMsg();
delete res;
delete msg;
throw LDAPException(resCode);
throw LDAPException(resCode, srvMsg);
}
}
......
......@@ -71,10 +71,11 @@ class LDAPConnection : private LDAPAsynConnection {
/**
* Start TLS on this connection. This isn't in the constructor,
* because it could fail (i.e. server doesn't have SSL cert, client
* api wasn't compiled against OpenSSL, etc.). If you need TLS,
* then you should error if this call fails with an error code.
* api wasn't compiled against OpenSSL, etc.).
* @throws LDAPException if the TLS Layer could not be setup
* correctly
*/
int start_tls();
void start_tls();
/**
* Performs a simple authentication with the server
......
......@@ -15,19 +15,19 @@
using namespace std;
LDAPException::LDAPException(int res_code, const string& err_string){
m_res_code=res_code;
m_res_string=string(ldap_err2string(res_code));
m_res_code=res_code;
m_res_string=string(ldap_err2string(res_code));
m_err_string=err_string;
}
LDAPException::LDAPException(const LDAPAsynConnection *lc){
m_err_string=string();
m_res_string=string();
LDAP *l = lc->getSessionHandle();
ldap_get_option(l,LDAP_OPT_ERROR_NUMBER,&m_res_code);
m_res_string=string(ldap_err2string(m_res_code));
m_err_string=string();
m_res_string=string();
LDAP *l = lc->getSessionHandle();
ldap_get_option(l,LDAP_OPT_ERROR_NUMBER,&m_res_code);
m_res_string=string(ldap_err2string(m_res_code));
char* err_string;
ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
ldap_get_option(l,LDAP_OPT_ERROR_STRING,&err_string);
m_err_string=string(err_string);
}
......@@ -35,11 +35,11 @@ LDAPException::~LDAPException(){
}
int LDAPException::getResultCode() const{
return m_res_code;
return m_res_code;
}
const string& LDAPException::getResultMsg() const{
return m_res_string;
return m_res_string;
}
const string& LDAPException::getServerMsg() const{
......
......@@ -85,5 +85,5 @@ noinst_HEADERS = LDAPAddRequest.h \
LDAPSearchRequest.h
libldapcpp_la_LIBADD = -lldap -llber
libldapcpp_la_LDFLAGS = -version-info 0:2:0
libldapcpp_la_LDFLAGS = -version-info 0:3:0
# Makefile.in generated by automake 1.7.2 from Makefile.am.
# Makefile.in generated by automake 1.9.5 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
......@@ -17,6 +17,9 @@
# Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
# COPYING RESTRICTIONS APPLY, see COPYRIGHT file
SOURCES = $(libldapcpp_la_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
......@@ -24,7 +27,6 @@ pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
......@@ -38,11 +40,66 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = src
DIST_COMMON = $(include_HEADERS) $(noinst_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/config.h.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libldapcpp_la_DEPENDENCIES =
am_libldapcpp_la_OBJECTS = LDAPAddRequest.lo LDAPAsynConnection.lo \
LDAPAttribute.lo LDAPAttributeList.lo LDAPAttrType.lo \
LDAPBindRequest.lo LDAPCompareRequest.lo LDAPConnection.lo \
LDAPConstraints.lo LDAPControl.lo LDAPControlSet.lo \
LDAPDeleteRequest.lo LDAPEntry.lo LDAPEntryList.lo \
LDAPException.lo LDAPExtRequest.lo LDAPExtResult.lo \
LDAPMessage.lo LDAPMessageQueue.lo LDAPModDNRequest.lo \
LDAPModification.lo LDAPModifyRequest.lo LDAPModList.lo \
LDAPObjClass.lo LDAPRebind.lo LDAPRebindAuth.lo \
LDAPReferralException.lo LDAPReferenceList.lo LDAPRequest.lo \
LDAPResult.lo LDAPSchema.lo LDAPSearchReference.lo \
LDAPSearchRequest.lo LDAPSearchResult.lo LDAPSearchResults.lo \
LDAPUrl.lo LDAPUrlList.lo StringList.lo
libldapcpp_la_OBJECTS = $(am_libldapcpp_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libldapcpp_la_SOURCES)
DIST_SOURCES = $(libldapcpp_la_SOURCES)
includeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(include_HEADERS) $(noinst_HEADERS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
......@@ -53,6 +110,7 @@ CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
......@@ -64,6 +122,8 @@ ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
......@@ -88,8 +148,10 @@ SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
......@@ -97,7 +159,10 @@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
......@@ -118,6 +183,7 @@ libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
......@@ -125,9 +191,7 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
lib_LTLIBRARIES = libldapcpp.la
libldapcpp_la_SOURCES = LDAPAddRequest.cpp \
LDAPAsynConnection.cpp \
LDAPAttribute.cpp \
......@@ -167,7 +231,6 @@ libldapcpp_la_SOURCES = LDAPAddRequest.cpp \
LDAPUrlList.cpp \
StringList.cpp
include_HEADERS = LDAPAsynConnection.h \
LDAPAttribute.h \
LDAPAttributeList.h \
......@@ -198,7 +261,6 @@ include_HEADERS = LDAPAsynConnection.h \
LDAPUrlList.h \
StringList.h
noinst_HEADERS = LDAPAddRequest.h \
LDAPBindRequest.h \
LDAPCompareRequest.h \
......@@ -209,96 +271,42 @@ noinst_HEADERS = LDAPAddRequest.h \
LDAPRequest.h \
LDAPSearchRequest.h
libldapcpp_la_LIBADD = -lldap -llber
libldapcpp_la_LDFLAGS = -version-info 0:1:0
subdir = src
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(lib_LTLIBRARIES)
libldapcpp_la_DEPENDENCIES =
am_libldapcpp_la_OBJECTS = LDAPAddRequest.lo LDAPAsynConnection.lo \
LDAPAttribute.lo LDAPAttributeList.lo LDAPAttrType.lo \
LDAPBindRequest.lo LDAPCompareRequest.lo LDAPConnection.lo \
LDAPConstraints.lo LDAPControl.lo LDAPControlSet.lo \
LDAPDeleteRequest.lo LDAPEntry.lo LDAPEntryList.lo \
LDAPException.lo LDAPExtRequest.lo LDAPExtResult.lo \
LDAPMessage.lo LDAPMessageQueue.lo LDAPModDNRequest.lo \
LDAPModification.lo LDAPModifyRequest.lo LDAPModList.lo \
LDAPObjClass.lo LDAPRebind.lo LDAPRebindAuth.lo \
LDAPReferralException.lo LDAPReferenceList.lo LDAPRequest.lo \
LDAPResult.lo LDAPSchema.lo LDAPSearchReference.lo \
LDAPSearchRequest.lo LDAPSearchResult.lo LDAPSearchResults.lo \
LDAPUrl.lo LDAPUrlList.lo StringList.lo
libldapcpp_la_OBJECTS = $(am_libldapcpp_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/LDAPAddRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPAsynConnection.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPAttrType.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPAttribute.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPAttributeList.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPBindRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPCompareRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPConnection.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPConstraints.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPControl.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPControlSet.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPDeleteRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPEntry.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPEntryList.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPException.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPExtRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPExtResult.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPMessage.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPMessageQueue.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPModDNRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPModList.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPModification.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPModifyRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPObjClass.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPRebind.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPRebindAuth.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPReferenceList.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPReferralException.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPResult.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPSchema.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPSearchReference.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPSearchRequest.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPSearchResult.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPSearchResults.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/LDAPUrl.Plo ./$(DEPDIR)/LDAPUrlList.Plo \
@AMDEP_TRUE@ ./$(DEPDIR)/StringList.Plo
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
DIST_SOURCES = $(libldapcpp_la_SOURCES)
HEADERS = $(include_HEADERS) $(noinst_HEADERS)
DIST_COMMON = $(include_HEADERS) $(noinst_HEADERS) Makefile.am \
Makefile.in config.h.in
SOURCES = $(libldapcpp_la_SOURCES)
libldapcpp_la_LDFLAGS = -version-info 0:3:0
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign src/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
config.h: stamp-h1
@if test ! -f $@; then \
......@@ -309,38 +317,37 @@ config.h: stamp-h1
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status src/config.h
$(srcdir)/config.h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/acconfig.h
$(srcdir)/config.h.in: $(am__configure_deps) $(top_srcdir)/acconfig.h
cd $(top_srcdir) && $(AUTOHEADER)
touch $(srcdir)/config.h.in
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
libLTLIBRARIES_INSTALL = $(INSTALL)
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(libdir)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" = "$$p" && dir=.; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
......@@ -348,7 +355,7 @@ libldapcpp.la: $(libldapcpp_la_OBJECTS) $(libldapcpp_la_DEPENDENCIES)
$(CXXLINK) -rpath $(libdir) $(libldapcpp_la_LDFLAGS) $(libldapcpp_la_OBJECTS) $(libldapcpp_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT) core *.core
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
......@@ -392,41 +399,26 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LDAPUrlList.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StringList.Plo@am__quote@
distclean-depend:
-rm -rf ./$(DEPDIR)
.cpp.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
@am__fastdepCXX_TRUE@ fi
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
@am__fastdepCXX_TRUE@ fi
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; \
@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
@am__fastdepCXX_TRUE@ fi
@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
......@@ -437,33 +429,24 @@ clean-libtool:
distclean-libtool:
-rm -f libtool
uninstall-info-am:
includeHEADERS_INSTALL = $(INSTALL_HEADER)
install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
$(mkinstalldirs) $(DESTDIR)$(includedir)
test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)"
@list='$(include_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f"; \
$(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f; \
f=$(am__strip_dir) \
echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
$(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
done
uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(include_HEADERS)'; for p in $$list; do \
f="`echo $$p | sed -e 's|^.*/||'`"; \
echo " rm -f $(DESTDIR)$(includedir)/$$f"; \
rm -f $(DESTDIR)$(includedir)/$$f; \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
rm -f "$(DESTDIR)$(includedir)/$$f"; \
done
ETAGS = etags
ETAGSFLAGS =
CTAGS = ctags
CTAGSFLAGS =
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
......@@ -472,6 +455,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
......@@ -483,10 +467,11 @@ TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
......@@ -509,10 +494,6 @@ GTAGS:
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = ..
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
......@@ -526,7 +507,7 @@ distdir: $(DISTFILES)
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
......@@ -544,10 +525,10 @@ distdir: $(DISTFILES)
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES) $(HEADERS) config.h
installdirs:
$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir)
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
......@@ -559,7 +540,7 @@ install-am: all-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
INSTALL_STRIP_FLAG=-s \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
......@@ -567,7 +548,7 @@ mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
......@@ -578,15 +559,17 @@ clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
distclean-am: clean-am distclean-compile distclean-depend \
distclean-generic distclean-hdr distclean-libtool \
distclean-tags
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
......@@ -602,7 +585,8 @@ install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
......@@ -623,9 +607,9 @@ uninstall-am: uninstall-includeHEADERS uninstall-info-am \
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libLTLIBRARIES clean-libtool ctags distclean \
distclean-compile distclean-depend distclean-generic \
distclean-hdr distclean-libtool distclean-tags distdir dvi \
dvi-am info info-am install install-am install-data \
distclean-compile distclean-generic distclean-hdr \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am \
install-includeHEADERS install-info install-info-am \
install-libLTLIBRARIES install-man install-strip installcheck \
......
/* Generic time.h */
/* $OpenLDAP$ */
/*
* Copyright 1998-2004 The OpenLDAP Foundation, Redwood City, California, USA
* Copyright 1998-2005 The OpenLDAP Foundation, Redwood City, California, USA
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted only
......
LDAP auxprop plugin for SASL-enabled servers.
Copyright (C) 2002,2003 by Howard Chu, hyc@symas.com
This software is licensed under the terms of the OpenLDAP license.
The file ldapdb.c was written for Cyrus SASL 2.1.3 and OpenLDAP 2.1.3.
Due to various bugs in the Cyrus source you should use Cyrus SASL 2.1.15
or newer. You need at least Cyrus SASL 2.1.16 to use the auxprop-store
functionality.
The version of ldapdb bundled with OpenLDAP 2.1.22 and older will work
with all OpenLDAP releases 2.1.3 and up. The ldapdb in OpenLDAP 2.1.23
uses a different LDAP request and requires the server to be 2.1.23 or newer.
It can be compiled by copying into the Cyrus SASL source tree, in the
plugins subdirectory. No configuration or build script is provided.
To compile, type "make ldapdb.lo". To link, you'll have to copy the
link rule for one of the other plugins. Below is a sample on my Linux
system:
/bin/sh ../libtool --mode=link gcc -Wall -W -g -O2 -L/usr/local/lib -Wl,-rpath,/usr/local/lib -module -export-dynamic -rpath /usr/lib/sasl2 -o libldapdb.la -version-info 2:4:0 ldapdb.lo -lldap -llber -lssl -lcrypto
Once installed, you need to add some config items to the SASL server's
config file in /usr/lib/sasl2. For example:
ldapdb_uri: ldap://ldap.example.com
ldapdb_id: root
ldapdb_pw: secret
ldapdb_mech: DIGEST-MD5
This config assumes an LDAP server on the same machine as the server
that is using SASL. The LDAP server must be configured to map the SASL
authcId "root" into a DN that has proxy authorization privileges to
every account that is allowed to login to this server. (See the OpenLDAP
Admin Guide section 10 for details.)
Unlike other LDAP-enabled plugins for other services that are common
on the web, this plugin does not require you to configure DN search
patterns to map usernames to LDAP DNs. This plugin requires SASL name
mapping to be configured on the target slapd. This approach keeps the
LDAP-specific configuration details in one place, the slapd.conf, and
makes the configuration of remote services much simpler.
An additional keyword "ldapdb_rc" may be specified in the config file.
The filename specified here will be put into the server's LDAPRC
environment variable, and libldap-specific config options may be set
in that ldaprc file. The main purpose behind this option is to allow
a client TLS certificate to be configured, so that SASL/EXTERNAL may
be used between the SASL server and the LDAP server. This is the most
optimal way to use this plugin when the servers are on separate machines.
Note: this plugin is not for use with slapd itself. When OpenLDAP is
built with SASL support, slapd uses its own internal auxprop module.
By default, without configuring anything else, slapd will fail to load
the ldapdb module when it's present. This is as it should be. If you
don't like the "auxpropfunc: error -7" message that is sent to syslog
by slapd, you can stop it by creating /usr/lib/sasl2/slapd.conf with:
auxprop_plugin: slapd
which will force the SASL library to ignore all other auxprop modules.
This plugin has been in use for over a year at many sites with good
results. If you have questions or problems, please send feedback via
the openldap-software mailing list.
-- Howard Chu
Update... With OpenLDAP 2.1.13 you can use SASL/EXTERNAL on ldapi://.
This is fast and secure, and needs no username or password to be stored.
The SASL config file is just
ldapdb_uri: ldapi://
ldapdb_mech: EXTERNAL
The slapd.conf will need to map these usernames to LDAP DNs:
sasl-regexp uidNumber=(.*)\\+gidNumber=(.*),cn=peercred,cn=external,cn=auth
ldap:///dc=example,dc=com??sub?(&(uidNumber=$1)(gidNumber=$2))
sasl-regexp uid=(.*),cn=external,cn=auth
ldap:///dc=example,dc=com??sub?(uid=$1)
Update... With OpenLDAP 2.1.23 you can use the ldapdb_starttls keyword
to use the StartTLS extended operation on an LDAP session. This item
may be set to either "try" or "demand", e.g.:
ldapdb_uri: ldap://ldap.example.com
ldapdb_starttls: try
When set to "try" any failure in StartTLS is ignored. When set to "demand"
then any failure aborts the connection.
/* $OpenLDAP$ */
/* SASL LDAP auxprop implementation
* Copyright (C) 2002,2003 Howard Chu, All rights reserved. <hyc@symas.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
#include <config.h>
#include <stdio.h>
#include "sasl.h"
#include "saslutil.h"
#include "saslplug.h"
#define SASL_VERSION_FULL ((SASL_VERSION_MAJOR << 16) |\
(SASL_VERSION_MINOR << 8) |SASL_VERSION_STEP)
#include "plugin_common.h"
#include <ldap.h>
static char ldapdb[] = "ldapdb";
typedef struct ldapctx {
const char *uri; /* URI of LDAP server */
struct berval id; /* SASL authcid to bind as */
struct berval pw; /* password for bind */
struct berval mech; /* SASL mech */
int use_tls; /* Issue StartTLS request? */
} ldapctx;
static int ldapdb_interact(LDAP *ld, unsigned flags __attribute__((unused)),
void *def, void *inter)
{
sasl_interact_t *in = inter;
ldapctx *ctx = def;
struct berval p;
for (;in->id != SASL_CB_LIST_END;in++)
{
p.bv_val = NULL;
switch(in->id)
{
case SASL_CB_GETREALM:
ldap_get_option(ld, LDAP_OPT_X_SASL_REALM, &p.bv_val);
if (p.bv_val) p.bv_len = strlen(p.bv_val);
break;
case SASL_CB_AUTHNAME:
p = ctx->id;
break;
case SASL_CB_PASS:
p = ctx->pw;
break;
}
if (p.bv_val)
{
in->result = p.bv_val;
in->len = p.bv_len;
}
}
return LDAP_SUCCESS;
}
typedef struct connparm {
LDAP *ld;
LDAPControl c;
LDAPControl *ctrl[2];
struct berval *dn;
} connparm;
static int ldapdb_connect(ldapctx *ctx, sasl_server_params_t *sparams,
const char *user, unsigned ulen, connparm *cp)
{
int i;
char *authzid;
if((i=ldap_initialize(&cp->ld, ctx->uri))) {
return i;
}
authzid = sparams->utils->malloc(ulen + sizeof("u:"));
if (!authzid) {
return LDAP_NO_MEMORY;
}
strcpy(authzid, "u:");
strcpy(authzid+2, user);
cp->c.ldctl_oid = LDAP_CONTROL_PROXY_AUTHZ;
cp->c.ldctl_value.bv_val = authzid;
cp->c.ldctl_value.bv_len = ulen + 2;
cp->c.ldctl_iscritical = 1;
i = LDAP_VERSION3;
ldap_set_option(cp->ld, LDAP_OPT_PROTOCOL_VERSION, &i);
/* If TLS is set and it fails, continue or bail out as requested */
if (ctx->use_tls && (i=ldap_start_tls_s(cp->ld, NULL, NULL)) != LDAP_SUCCESS
&& ctx->use_tls > 1) {
sparams->utils->free(authzid);
return i;
}
i = ldap_sasl_interactive_bind_s(cp->ld, NULL, ctx->mech.bv_val, NULL,
NULL, LDAP_SASL_QUIET, ldapdb_interact, ctx);
if (i != LDAP_SUCCESS) {
sparams->utils->free(authzid);
return i;
}
cp->ctrl[0] = &cp->c;
cp->ctrl[1] = NULL;
i = ldap_whoami_s(cp->ld, &cp->dn, cp->ctrl, NULL);
if (i == LDAP_SUCCESS && cp->dn) {
if (!cp->dn->bv_val || strncmp(cp->dn->bv_val, "dn:", 3)) {
ber_bvfree(cp->dn);
cp->dn = NULL;
i = LDAP_INVALID_SYNTAX;
} else {
cp->c.ldctl_value = *(cp->dn);
}
}
sparams->utils->free(authzid);
return i;
}
static void ldapdb_auxprop_lookup(void *glob_context,
sasl_server_params_t *sparams,
unsigned flags,
const char *user,
unsigned ulen)
{
ldapctx *ctx = glob_context;
connparm cp;
int ret, i, n, *aindx;
const struct propval *pr;
struct berval **bvals;
LDAPMessage *msg, *res;
char **attrs = NULL;
if(!ctx || !sparams || !user) return;
pr = sparams->utils->prop_get(sparams->propctx);
if(!pr) return;
/* count how many attrs to fetch */
for(i = 0, n = 0; pr[i].name; i++) {
if(pr[i].name[0] == '*' && (flags & SASL_AUXPROP_AUTHZID))
continue;
if(pr[i].values && !(flags & SASL_AUXPROP_OVERRIDE))
continue;
n++;
}
/* nothing to do, bail out */
if (!n) return;
/* alloc an array of attr names for search, and index to the props */
attrs = sparams->utils->malloc((n+1)*sizeof(char *)*2);
if (!attrs) return;
aindx = (int *)(attrs + n + 1);
/* copy attr list */
for (i=0, n=0; pr[i].name; i++) {
if(pr[i].name[0] == '*' && (flags & SASL_AUXPROP_AUTHZID))
continue;
if(pr[i].values && !(flags & SASL_AUXPROP_OVERRIDE))
continue;
attrs[n] = (char *)pr[i].name;
if (pr[i].name[0] == '*') attrs[n]++;
aindx[n] = i;
n++;
}
attrs[n] = NULL;
if(ldapdb_connect(ctx, sparams, user, ulen, &cp)) {
goto done;
}
ret = ldap_search_ext_s(cp.ld, cp.dn->bv_val+3, LDAP_SCOPE_BASE,
"(objectclass=*)", attrs, 0, cp.ctrl, NULL, NULL, 1, &res);
ber_bvfree(cp.dn);
if (ret != LDAP_SUCCESS) goto done;
for(msg=ldap_first_message(cp.ld, res); msg; msg=ldap_next_message(cp.ld, msg))
{
if (ldap_msgtype(msg) != LDAP_RES_SEARCH_ENTRY) continue;
for (i=0; i<n; i++)
{
bvals = ldap_get_values_len(cp.ld, msg, attrs[i]);
if (!bvals) continue;
if (pr[aindx[i]].values)
sparams->utils->prop_erase(sparams->propctx, pr[aindx[i]].name);
sparams->utils->prop_set(sparams->propctx, pr[aindx[i]].name,
bvals[0]->bv_val, bvals[0]->bv_len);
ber_bvecfree(bvals);
}
}
ldap_msgfree(res);
done:
if(attrs) sparams->utils->free(attrs);
if(cp.ld) ldap_unbind(cp.ld);
}
#if SASL_VERSION_FULL >= 0x020110
static int ldapdb_auxprop_store(void *glob_context,
sasl_server_params_t *sparams,
struct propctx *prctx,
const char *user,
unsigned ulen)
{
ldapctx *ctx = glob_context;
connparm cp;
const struct propval *pr;
int i, n;
LDAPMod **mods;
/* just checking if we are enabled */
if (!prctx) return SASL_OK;
if (!sparams || !user) return SASL_BADPARAM;
pr = sparams->utils->prop_get(prctx);
if (!pr) return SASL_BADPARAM;
for (n=0; pr[n].name; n++);
if (!n) return SASL_BADPARAM;
mods = sparams->utils->malloc((n+1) * sizeof(LDAPMod*) + n * sizeof(LDAPMod));
if (!mods) return SASL_NOMEM;
if((i=ldapdb_connect(ctx, sparams, user, ulen, &cp)) == 0) {
for (i=0; i<n; i++) {
mods[i] = (LDAPMod *)((char *)(mods+n+1) + i * sizeof(LDAPMod));
mods[i]->mod_op = LDAP_MOD_REPLACE;
mods[i]->mod_type = (char *)pr[i].name;
mods[i]->mod_values = (char **)pr[i].values;
}
mods[i] = NULL;
i = ldap_modify_ext_s(cp.ld, cp.dn->bv_val+3, mods, cp.ctrl, NULL);
ber_bvfree(cp.dn);
}
sparams->utils->free(mods);
if (i) {
sparams->utils->seterror(sparams->utils->conn, 0,
ldap_err2string(i));
if (i == LDAP_NO_MEMORY) i = SASL_NOMEM;
else i = SASL_FAIL;
}
if (cp.ld) ldap_unbind(cp.ld);
return i;
}
#endif /* SASL_VERSION_FULL >= 2.1.16 */
static void ldapdb_auxprop_free(void *glob_ctx, const sasl_utils_t *utils)
{
utils->free(glob_ctx);
}
static sasl_auxprop_plug_t ldapdb_auxprop_plugin = {
0, /* Features */
0, /* spare */
NULL, /* glob_context */
ldapdb_auxprop_free, /* auxprop_free */
ldapdb_auxprop_lookup, /* auxprop_lookup */
ldapdb, /* name */
#if SASL_VERSION_FULL >=0x020110
ldapdb_auxprop_store /* spare if <2.1.16*/
#else
NULL
#endif
};
static int ldapdb_auxprop_plug_init(const sasl_utils_t *utils,
int max_version,
int *out_version,
sasl_auxprop_plug_t **plug,
const char *plugname __attribute__((unused)))
{
ldapctx tmp, *p;
const char *s;
unsigned len;
if(!out_version || !plug) return SASL_BADPARAM;
if(max_version < SASL_AUXPROP_PLUG_VERSION) return SASL_BADVERS;
memset(&tmp, 0, sizeof(tmp));
utils->getopt(utils->getopt_context, ldapdb, "ldapdb_uri", &tmp.uri, NULL);
if(!tmp.uri) return SASL_BADPARAM;
utils->getopt(utils->getopt_context, ldapdb, "ldapdb_id",
(const char **)&tmp.id.bv_val, &len);
tmp.id.bv_len = len;
utils->getopt(utils->getopt_context, ldapdb, "ldapdb_pw",
(const char **)&tmp.pw.bv_val, &len);
tmp.pw.bv_len = len;
utils->getopt(utils->getopt_context, ldapdb, "ldapdb_mech",
(const char **)&tmp.mech.bv_val, &len);
tmp.mech.bv_len = len;
utils->getopt(utils->getopt_context, ldapdb, "ldapdb_starttls", &s, NULL);
if (s)
{
if (!strcasecmp(s, "demand")) tmp.use_tls = 2;
else if (!strcasecmp(s, "try")) tmp.use_tls = 1;
}
utils->getopt(utils->getopt_context, ldapdb, "ldapdb_rc", &s, &len);
if (s)
{
char *str = utils->malloc(sizeof("LDAPRC=")+len);
if (!str) return SASL_NOMEM;
strcpy( str, "LDAPRC=" );
strcpy( str + sizeof("LDAPRC=")-1, s );
if (putenv(str))
{
utils->free(str);
return SASL_NOMEM;
}
}
p = utils->malloc(sizeof(ldapctx));
if (!p) return SASL_NOMEM;
*p = tmp;
ldapdb_auxprop_plugin.glob_context = p;
*out_version = SASL_AUXPROP_PLUG_VERSION;
*plug = &ldapdb_auxprop_plugin;
return SASL_OK;
}
SASL_AUXPROP_PLUG_INIT( ldapdb )
Package rersion 2.0:
- Detects OpenLDAP 2.0 and builds correctly with it.
- Increment major version to 2, library file to libldaptcl2.0.so.
- Can now perform add/delete/replace modifications in a single command.
- Replaced calls to TclX_WrongArgs with core Tcl_WrongNumArgs to reduce
dependency on Extended Tcl.
- Wrap dereference search control with #ifdef LDAP_OPT_DEREF.
- Deref during search should work.
- Add protocol_version option to ldap init command.
- Add LDAPTCL_PROTOCOL_VERSION_DEFAULT to allow specifying the default
protocol version used.
- Add controlArray(timeout) to control timeouts during searches.
- Add controlArray(cache) to control caching current search results.
(Experience has shown this to be not very useful or not working correctly.
Caching search results should probably be done in Ldaptcl rather than
letting the LDAP API do it.)
- Add "compare" subcommand
- Add experimental trap subcommand (undocumented -- use at your own risk).
Package version 1.2:
- Filter no longer a required controlArray member, defaults to objectclass=*.
- Sets errorCode with LDAP macro string value (better to test than the more
human readable values).
- Shorten minimum required characters for search scope definitions: now allows
"base", "one", and "sub". For the latter two, additional characters are
ignored.
- Now compiles successfully with -devel branch.
- Client cache management code enabled for OpenLDAP versions <= 1.2.4. (This
code is relatively untested and feedback is welcome.)
NeoSoft Tcl client extensions to Lightweight Directory Access Protocol.
Copyright (c) 1998-1999 NeoSoft, Inc.
All Rights Reserved.
This software may be used, modified, copied, distributed, and sold,
in both source and binary form provided that these copyrights are
retained and their terms are followed.
Under no circumstances are the authors or NeoSoft Inc. responsible
for the proper functioning of this software, nor do the authors
assume any liability for damages incurred with its use.
Redistribution and use in source and binary forms are permitted
provided that this notice is preserved and that due credit is given
to NeoSoft, Inc.
NeoSoft, Inc. may not be used to endorse or promote products derived
from this software without specific prior written permission. This
software is provided ``as is'' without express or implied warranty.
Requests for permission may be sent to NeoSoft Inc, 1770 St. James Place,
Suite 500, Houston, TX, 77056.
#
# This file is a Makefile for Neo, the NeoSoft extensions to Tcl.
# If it has the name "Makefile.in" then it is a template for a
# Makefile; to generate the actual Makefile, run "./configure",
# which is a configuration script generated by the "autoconf" program
# (constructs like "@foo@" will get replaced in the actual Makefile.
#
VERSION = @NEO_VERSION@
LIBNAME = @NEO_SHARED_LIB_FILE@
# Default top-level directories in which to install architecture-
# specific files (exec_prefix) and machine-independent files such
# as scripts (prefix). The values specified here may be overridden
# at configure-time with the --exec-prefix and --prefix options
# to the "configure" script.
prefix = @prefix@
exec_prefix = @exec_prefix@
# The following definition can be set to non-null for special systems
# like AFS with replication. It allows the pathnames used for installation
# to be different than those used for actually reference files at
# run-time. DESTDIR is prepended to $prefix and $exec_prefix
# when installing files.
DESTDIR =
# Directory in which to search for tcl libraries
NEO_LIBRARY = $(exec_prefix)/lib/ldaptcl$(VERSION)
# Directory in which to install the ldaptcl binary:
BIN_INSTALL_DIR = $(DESTDIR)$(exec_prefix)/bin
# Directory in which to install the .a or .so binary for the Neo library:
LIB_INSTALL_DIR = $(DESTDIR)$(exec_prefix)/lib
# Path to use at runtime to refer to LIB_INSTALL_DIR:
LIB_RUNTIME_DIR = $(exec_prefix)/lib
# Top-level directory for man entries:
MANN_INSTALL_DIR = $(DESTDIR)$(prefix)/man/mann
# The symbols below provide support for dynamic loading and shared
# libraries. The values of the symbols are normally set by the
# configure script. You shouldn't normally need to modify any of
# these definitions by hand.
SHLIB_CFLAGS = @NEO_SHLIB_CFLAGS@
NEO_LIB_FILE = @NEO_LIB_FILE@
NEO_SHARED_LIB_FILE = @NEO_SHARED_LIB_FILE@
# The directory containing the Tcl sources and headers appropriate
# for this version of Neo ("srcdir" will be replaced or has already
# been replaced by the configure script):
TCL_GENERIC_DIR = @TCL_SRC_DIR@/generic
# The top of the TclX directory tree
TCLX_TOP_DIR = @TCLX_TOP_DIR@
# The directory where tclExtend.h will be:
TCLX_TCL_GEN_DIR = ${TCLX_TOP_DIR}/tcl/generic
# The directory where tclXunixPort.h will be:
TCLX_TCL_UNIX_DIR = ${TCLX_TOP_DIR}/tcl/unix
# The path to tclX the runtcl script:
TCLX_RUNTCL = ${TCLX_TOP_DIR}/unix/runtcl
# The directory containing the Tcl library archive file appropriate
# for this version of Neo:
TCL_BIN_DIR = @TCL_BIN_DIR@
# The symbol below provides support for dynamic loading and shared
# libraries. See configure.in for a description of what it means.
# The values of the symbolis normally set by the configure script.
SHLIB_LD = @SHLIB_LD@
# Set to the options to include libldap.a and liblber.a
# (eg. -L../tools/blah -lldap -llber)
LDAP_LIBFLAGS = @ldaplibflags@
LDAP_CFLAGS = @ldapinclude@
LDAP_INCDIR = @ldapincdir@
LDAP_BUILD = @ldapbuild@
LDAP_DIR = @ldapdir@
#----------------------------------------------------------------
# The information below is modified by the configure script when
# Makefile is generated from Makefile.in. You shouldn't normally
# modify any of this stuff by hand.
#----------------------------------------------------------------
AC_FLAGS = @DEFS@
INSTALL= @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
RANLIB = @RANLIB@
SRC_DIR = @srcdir@/..
TOP_DIR = @srcdir@/..
GENERIC_DIR = $(TOP_DIR)/generic
#----------------------------------------------------------------
# The information below should be usable as is. The configure
# script won't modify it and you shouldn't need to modify it
# either.
#----------------------------------------------------------------
OBJS= neoXldap.o
LIBDIR=$(exec_prefix)/lib
INCDIR=$(prefix)/include
LIBS= @LIBS@ @TCLX_LIB_SPEC@ @TCL_LIB_SPEC@ @TCL_LIBS@ $(LDAP_LIBFLAGS) -lc
TK_LIBS=@TKX_LIB_SPEC@ @TK_LIB_SPEC@ @TK_LIBS@
TK_VERSION=@TK_VERSION@
CC = @CC@
CC_SWITCHES = ${CFLAGS} @NEO_SHLIB_CFLAGS@ -I. \
-I@prefix@/include ${AC_FLAGS} ${PROTO_FLAGS} \
${SECURITY_FLAGS} ${MEM_DEBUG_FLAGS} ${KEYSYM_FLAGS} \
-DNEO_LIBRARY=\"${NEO_LIBRARY}\" -DVERSION=\"${VERSION}\"
TK_SWITCHES = ${CC_SWITCHES} @TK_XINCLUDES@
.c.o:
$(CC) -c $(CC_SWITCHES) $<
all: @NEO_LIB_FILE@ ldaptclsh @LDAPWISH@
@NEO_LIB_FILE@: $(OBJS)
rm -f @NEO_LIB_FILE@
@MAKE_LIB@
$(RANLIB) @NEO_LIB_FILE@
neoXldap.o: neoXldap.c ldaptclerr.h
$(CC) -c $(LDAP_CFLAGS) $(CC_SWITCHES) $<
ldaptclerr.h: ldaperr.tcl
tcl ldaperr.tcl $(LDAP_INCDIR)/ldap.h > ldaptclerr.h
clean:
-rm -f ldaptclsh ldapwish
-rm -f *.o *.a *.so*
distclean: clean
rm -f Makefile pkgIndex.tcl config.cache config.log config.status \
ldaptclerr.h
install: install-binaries install-man
install-binaries: @NEO_LIB_FILE@ ldaptclsh @LDAPWISH@
@-mkdir -p $(BIN_INSTALL_DIR)
$(INSTALL_PROGRAM) ldaptclsh $(BIN_INSTALL_DIR)/ldaptclsh
@if [ -n "@LDAPWISH@" ] ; then \
echo $(INSTALL_PROGRAM) ldapwish $(BIN_INSTALL_DIR)/ldapwish; \
$(INSTALL_PROGRAM) ldapwish $(BIN_INSTALL_DIR)/ldapwish; \
fi
$(INSTALL_DATA) @NEO_LIB_FILE@ $(LIB_INSTALL_DIR)
@if [ "$(NEO_LIB_FILE)" = "$(NEO_SHARED_LIB_FILE)" ] ; then \
echo Installing pkgIndex.tcl in $(NEO_LIBRARY); \
mkdir -p $(NEO_LIBRARY); \
$(INSTALL_DATA) pkgIndex.tcl $(NEO_LIBRARY); \
fi
install-man:
@for i in ldap.n; \
do \
echo "Installing $$i"; \
rm -f $(MANN_INSTALL_DIR)/$$i; \
sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
$$i > $(MANN_INSTALL_DIR)/$$i; \
chmod 444 $(MANN_INSTALL_DIR)/$$i; \
done;
TCLOFILES= tclAppInit.o
ldaptclsh:$(TCLOFILES) @NEO_LIB_FILE@
$(CC) @LD_FLAGS@ $(TCLOFILES) @NEO_BUILD_LIB_SPEC@ $(LIBS) \
@TCL_LD_SEARCH_FLAGS@ -o ldaptclsh
tkAppInit.o: tkAppInit.c
$(CC) -c ${TK_SWITCHES} tkAppInit.c
ldapwish:tkAppInit.o @NEO_LIB_FILE@
$(CC) @LD_FLAGS@ tkAppInit.o @NEO_BUILD_LIB_SPEC@ $(TK_LIBS) $(LIBS) \
@TCL_LD_SEARCH_FLAGS@ -o ldapwish
Copyright (c) 1998-1999 NeoSoft, Inc.
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
community, it is the authors' intention that support continue (and
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. The default configuration supports
OpenLDAP 1.2.4 and above.
OpenLDAP 2.x is supported, but there is not yet any support for
using SASL or TLS. There may be interface changes in the LDAP API
which the author is unaware of (a leak was recently fixed for the
return values of ldap_first/next_attribute() calls).
It uses GNU autoconf. It builds and installs without requiring
parallel directories, but it does require that Tcl and Extended Tcl
are installed in the directory pointed to by --prefix (/usr/local
by default).
For further info, try "./configure --help".
For example, I run:
./configure --prefix=/opt/neotcl --enable-shared \
--with-ldap=/usr/local/ldap
Remember that --prefix must be the same prefix used when building
and installint Tcl.
Netscape configuration has not been well tested, and you may have to
play with the resulting Makefile to get it to work. In particular,
you will probably need to modify the LDAP_LIBFLAGS. However, the
C code itself is reasonably well tested with Netscape.
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 you must also use --enable-shared here.
Shared libraries and Tcl packages.
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
possible to run a plain Tcl interpreter (eg. tclsh8.0) and do
package require Ldaptcl
which will install the "ldap" command into the interpreter.
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 Alpha OSF4.0e with the native C
compiler.
Please email comments or bug fixes to openldap-devel@OpenLDAP.org,
or to kunkee@OpenLDAP.org. I would also like to know if you are
using this interface, so I invite you to drop me an email if you do.
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13
# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
# Defaults:
ac_help=
ac_default_prefix=/usr/local
# Any additions from configure.in:
ac_help="$ac_help
--enable-gcc allow use of gcc if available"
ac_help="$ac_help
--with-tk=DIR use Tk 8.0 binaries from DIR"
ac_help="$ac_help
--without-x do not build/install ldapwish"
ac_help="$ac_help
--enable-shared build libldaptcl as a shared library"
ac_help="$ac_help
--with-ldap=<dir> common parent of ldap include and lib dirs"
ac_help="$ac_help
--with-ldap-incdir=<dir> path to ldap.h"
ac_help="$ac_help
--with-ldap-libdir=<dir> path to ldap and lber libs"
ac_help="$ac_help
--with-ldap-libflags=<libnames> -l flags for ldap libraries"
# Initialize some variables set by options.
# The variables have the same names as the options, with
# dashes changed to underlines.
build=NONE
cache_file=./config.cache
exec_prefix=NONE
host=NONE
no_create=
nonopt=NONE
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
target=NONE
verbose=
x_includes=NONE
x_libraries=NONE
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datadir='${prefix}/share'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'
# Initialize some other variables.
subdirs=
MFLAGS= MAKEFLAGS=
SHELL=${CONFIG_SHELL-/bin/sh}
# Maximum number of lines to put in a shell here document.
ac_max_here_lines=12
ac_prev=
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval "$ac_prev=\$ac_option"
ac_prev=
continue
fi
case "$ac_option" in
-*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) ac_optarg= ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case "$ac_option" in
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir="$ac_optarg" ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build="$ac_optarg" ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file="$ac_optarg" ;;
-datadir | --datadir | --datadi | --datad | --data | --dat | --da)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
| --da=*)
datadir="$ac_optarg" ;;
-disable-* | --disable-*)
ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
fi
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
eval "enable_${ac_feature}=no" ;;
-enable-* | --enable-*)
ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
{ echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
fi
ac_feature=`echo $ac_feature| sed 's/-/_/g'`
case "$ac_option" in
*=*) ;;
*) ac_optarg=yes ;;
esac
eval "enable_${ac_feature}='$ac_optarg'" ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix="$ac_optarg" ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he)
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat << EOF
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
--cache-file=FILE cache test results in FILE
--help print this message
--no-create do not create output files
--quiet, --silent do not print \`checking...' messages
--version print the version of autoconf that created configure
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
[$ac_default_prefix]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data in DIR
[PREFIX/share]
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data in DIR
[PREFIX/com]
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM
run sed PROGRAM on installed program names
EOF
cat << EOF
Host type:
--build=BUILD configure for building on BUILD [BUILD=HOST]
--host=HOST configure for HOST [guessed]
--target=TARGET configure for TARGET [TARGET=HOST]
Features and packages:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
EOF
if test -n "$ac_help"; then
echo "--enable and --with options recognized:$ac_help"
fi
exit 0 ;;
-host | --host | --hos | --ho)
ac_prev=host ;;
-host=* | --host=* | --hos=* | --ho=*)
host="$ac_optarg" ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir="$ac_optarg" ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir="$ac_optarg" ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir="$ac_optarg" ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir="$ac_optarg" ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst \
| --locals | --local | --loca | --loc | --lo)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* \
| --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
localstatedir="$ac_optarg" ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir="$ac_optarg" ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir="$ac_optarg" ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix="$ac_optarg" ;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix="$ac_optarg" ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix="$ac_optarg" ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name="$ac_optarg" ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir="$ac_optarg" ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir="$ac_optarg" ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site="$ac_optarg" ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir="$ac_optarg" ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir="$ac_optarg" ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target="$ac_optarg" ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers)
echo "configure generated by autoconf version 2.13"
exit 0 ;;
-with-* | --with-*)
ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
fi
ac_package=`echo $ac_package| sed 's/-/_/g'`
case "$ac_option" in
*=*) ;;
*) ac_optarg=yes ;;
esac
eval "with_${ac_package}='$ac_optarg'" ;;
-without-* | --without-*)
ac_package=`echo $ac_option|sed -e 's/-*without-//'`
# Reject names that are not valid shell variable names.
if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
{ echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
fi
ac_package=`echo $ac_package| sed 's/-/_/g'`
eval "with_${ac_package}=no" ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes="$ac_optarg" ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries="$ac_optarg" ;;
-*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
;;
*)
if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
echo "configure: warning: $ac_option: invalid host type" 1>&2
fi
if test "x$nonopt" != xNONE; then
{ echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
fi
nonopt="$ac_option"
;;
esac
done
if test -n "$ac_prev"; then
{ echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
fi
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
# File descriptor usage:
# 0 standard input
# 1 file creation
# 2 errors and warnings
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 6 checking for... messages and results
# 5 compiler messages saved in config.log
if test "$silent" = yes; then
exec 6>/dev/null
else
exec 6>&1
fi
exec 5>./config.log
echo "\
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
" 1>&5
# Strip out --no-create and --no-recursion so they do not pile up.
# Also quote any args containing shell metacharacters.
ac_configure_args=
for ac_arg
do
case "$ac_arg" in
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c) ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
*" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
ac_configure_args="$ac_configure_args '$ac_arg'" ;;
*) ac_configure_args="$ac_configure_args $ac_arg" ;;
esac
done
# NLS nuisances.
# Only set these to C if already set. These must not be set unconditionally
# because not all systems understand e.g. LANG=C (notably SCO).
# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
# Non-C LC_CTYPE values break the ctype check.
if test "${LANG+set}" = set; then LANG=C; export LANG; fi
if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -rf conftest* confdefs.h
# AIX cpp loses on an empty file, so make sure it contains at least a newline.
echo > confdefs.h
# A filename unique to this package, relative to the directory that
# configure is in, which we can look for to find out if srcdir is correct.
ac_unique_file=neoXldap.c
# Find the source files, if location was not specified.
if test -z "$srcdir"; then
ac_srcdir_defaulted=yes
# Try the directory containing this script, then its parent.
ac_prog=$0
ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
srcdir=$ac_confdir
if test ! -r $srcdir/$ac_unique_file; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
if test ! -r $srcdir/$ac_unique_file; then
if test "$ac_srcdir_defaulted" = yes; then
{ echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
else
{ echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
fi
fi
srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
# Prefer explicitly selected file to automatically selected ones.
if test -z "$CONFIG_SITE"; then
if test "x$prefix" != xNONE; then
CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
else
CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
fi
fi
for ac_site_file in $CONFIG_SITE; do
if test -r "$ac_site_file"; then
echo "loading site script $ac_site_file"
. "$ac_site_file"
fi
done
if test -r "$cache_file"; then
echo "loading cache $cache_file"
. $cache_file
else
echo "creating cache $cache_file"
> $cache_file
fi
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
ac_exeext=
ac_objext=o
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
# Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
ac_n= ac_c='
' ac_t=' '
else
ac_n=-n ac_c= ac_t=
fi
else
ac_n= ac_c='\c' ac_t=
fi
# $OpenLDAP$
NEO_VERSION=2.0
NEO_MAJOR_VERSION=2
NEO_MINOR_VERSION=0
VERSION=${NEO_VERSION}
if test "${prefix}" = "NONE"; then
prefix=/usr/local
fi
if test "${exec_prefix}" = "NONE"; then
exec_prefix=$prefix
fi
# Check whether --enable-gcc or --disable-gcc was given.
if test "${enable_gcc+set}" = set; then
enableval="$enable_gcc"
neo_ok=$enableval
else
neo_ok=no
fi
if test "$neo_ok" = "yes"; then
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:567: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="gcc"
break
fi
done
IFS="$ac_save_ifs"
fi
fi
CC="$ac_cv_prog_CC"
if test -n "$CC"; then
echo "$ac_t""$CC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:597: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_prog_rejected=no
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
fi
ac_cv_prog_CC="cc"
break
fi
done
IFS="$ac_save_ifs"
if test $ac_prog_rejected = yes; then
# We found a bogon in the path, so make sure we never use it.
set dummy $ac_cv_prog_CC
shift
if test $# -gt 0; then
# We chose a different compiler from the bogus one.
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
set dummy "$ac_dir/$ac_word" "$@"
shift
ac_cv_prog_CC="$@"
fi
fi
fi
fi
CC="$ac_cv_prog_CC"
if test -n "$CC"; then
echo "$ac_t""$CC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test -z "$CC"; then
case "`uname -s`" in
*win32* | *WIN32*)
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:648: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_CC="cl"
break
fi
done
IFS="$ac_save_ifs"
fi
fi
CC="$ac_cv_prog_CC"
if test -n "$CC"; then
echo "$ac_t""$CC" 1>&6
else
echo "$ac_t""no" 1>&6
fi
;;
esac
fi
test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:680: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
#line 691 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
if { (eval echo configure:696: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
ac_cv_prog_cc_cross=no
else
ac_cv_prog_cc_cross=yes
fi
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_prog_cc_works=no
fi
rm -fr conftest*
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross
echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
echo "configure:722: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
echo "configure:727: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.c <<EOF
#ifdef __GNUC__
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:736: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
fi
fi
echo "$ac_t""$ac_cv_prog_gcc" 1>&6
if test $ac_cv_prog_gcc = yes; then
GCC=yes
else
GCC=
fi
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
echo "configure:755: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo 'void f(){}' > conftest.c
if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
ac_cv_prog_cc_g=yes
else
ac_cv_prog_cc_g=no
fi
rm -f conftest*
fi
echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
else
CC=${CC-cc}
fi
ac_aux_dir=
for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
if test -f $ac_dir/install-sh; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install-sh -c"
break
elif test -f $ac_dir/install.sh; then
ac_aux_dir=$ac_dir
ac_install_sh="$ac_aux_dir/install.sh -c"
break
fi
done
if test -z "$ac_aux_dir"; then
{ echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
fi
ac_config_guess=$ac_aux_dir/config.guess
ac_config_sub=$ac_aux_dir/config.sub
ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
# Find a good install program. We prefer a C program (faster),
# so one script is as good as another. But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:822: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
for ac_dir in $PATH; do
# Account for people who put trailing slashes in PATH elements.
case "$ac_dir/" in
/|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
*)
# OSF1 and SCO ODT 3.0 have their own names for install.
# Don't use installbsd from OSF since it installs stuff as root
# by default.
for ac_prog in ginstall scoinst install; do
if test -f $ac_dir/$ac_prog; then
if test $ac_prog = install &&
grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
# AIX install. It has an incompatible calling convention.
:
else
ac_cv_path_install="$ac_dir/$ac_prog -c"
break 2
fi
fi
done
;;
esac
done
IFS="$ac_save_IFS"
fi
if test "${ac_cv_path_install+set}" = set; then
INSTALL="$ac_cv_path_install"
else
# As a last resort, use the slow shell script. We don't cache a
# path for INSTALL within a source directory, because that will
# break other packages using the cache if that directory is
# removed, or if the path is relative.
INSTALL="$ac_install_sh"
fi
fi
echo "$ac_t""$INSTALL" 1>&6
# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:877: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test -n "$RANLIB"; then
ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
ac_dummy="$PATH"
for ac_dir in $ac_dummy; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/$ac_word; then
ac_cv_prog_RANLIB="ranlib"
break
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":"
fi
fi
RANLIB="$ac_cv_prog_RANLIB"
if test -n "$RANLIB"; then
echo "$ac_t""$RANLIB" 1>&6
else
echo "$ac_t""no" 1>&6
fi
if test ! -f $exec_prefix/lib/tclConfig.sh
then
{ echo "configure: error: Tcl must be installed first" 1>&2; exit 1; }
fi
. $exec_prefix/lib/tclConfig.sh
if test ! -f $exec_prefix/lib/tclxConfig.sh
then
{ echo "configure: error: Extended Tcl must be installed first" 1>&2; exit 1; }
fi
. $exec_prefix/lib/tclxConfig.sh
#--------------------------------------------------------------------
# See if there was a command-line option for where Tk is; if
# not, assume that its top-level directory is a sibling of ours.
#--------------------------------------------------------------------
# Check whether --with-tk or --without-tk was given.
if test "${with_tk+set}" = set; then
withval="$with_tk"
:
else
with_tk=yes
fi
case "$with_tk" in
yes)
if test -f $exec_prefix/lib/tkConfig.sh -a $exec_prefix/lib/tkxConfig.sh
then
:
else
{ echo "configure: error: Tk does not appear to be installed at $exec_prefix" 1>&2; exit 1; }
fi
;;
no) ;;
*) { echo "configure: error: Tk cannot be specified and must be in $exec_prefix" 1>&2; exit 1; }
;;
esac
# Check whether --with-x or --without-x was given.
if test "${with_x+set}" = set; then
withval="$with_x"
:
fi
if test "$with_x" = "no"
then
with_tk=no
fi
if test "$with_tk" != "no"
then
LDAPWISH=ldapwish
. $exec_prefix/lib/tkConfig.sh
. $exec_prefix/lib/tkxConfig.sh
fi
#--------------------------------------------------------------------
# Read in configuration information generated by Tcl for shared
# libraries, and arrange for it to be substituted into our
# Makefile.
#--------------------------------------------------------------------
CC=$TCL_CC
SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
SHLIB_LD=$TCL_SHLIB_LD
SHLIB_LD_LIBS=$TCL_SHLIB_LD_LIBS
SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
SHLIB_VERSION=$TCL_SHLIB_VERSION
DL_LIBS=$TCL_DL_LIBS
LD_FLAGS=$TCL_LD_FLAGS
NEO_LD_SEARCH_FLAGS=$TCL_LD_SEARCH_FLAGS
eval "NEO_SHARED_LIB_FILE=libldaptcl${TCL_SHARED_LIB_SUFFIX}"
eval "NEO_UNSHARED_LIB_FILE=libldaptcl${TCL_UNSHARED_LIB_SUFFIX}"
#--------------------------------------------------------------------
# The statements below define a collection of symbols related to
# building libldap as a shared library instead of a static library.
#--------------------------------------------------------------------
# Warning: in order to use the following code for libldap and libdb versions,
# the VERSION shell variable is modified, and then is restored after.
# Check whether --enable-shared or --disable-shared was given.
if test "${enable_shared+set}" = set; then
enableval="$enable_shared"
ok=$enableval
else
ok=no
fi
if test "$ok" = "yes" -a "${SHLIB_SUFFIX}" != ""; then
NEO_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
eval "NEO_LIB_FILE=libldaptcl${TCL_SHARED_LIB_SUFFIX}"
MAKE_LIB="\${SHLIB_LD} $TCL_LIB_HNAME -o ${NEO_LIB_FILE} \${OBJS} \${LDAP_LIBFLAGS}"
RANLIB=":"
else
NEO_SHLIB_CFLAGS=""
eval "NEO_LIB_FILE=libldaptcl${TCL_UNSHARED_LIB_SUFFIX}"
MAKE_LIB="ar cr ${NEO_LIB_FILE} \${OBJS}"
fi
# Check whether --with-ldap or --without-ldap was given.
if test "${with_ldap+set}" = set; then
withval="$with_ldap"
neo_ldap=$withval
case $withval in
yes) ldapdir=/usr/local
;;
no) ;;
*) ldapdir=$withval
neo_ldap=yes
;;
esac
else
neo_ldap=yes
ldapdir=/usr/local
fi
ldapincdir=$ldapdir/include
# Check whether --with-ldap-incdir or --without-ldap-incdir was given.
if test "${with_ldap_incdir+set}" = set; then
withval="$with_ldap_incdir"
ldapincdir=$withval
fi
ldaplibdir=$ldapdir/lib
# Check whether --with-ldap-libdir or --without-ldap-libdir was given.
if test "${with_ldap_libdir+set}" = set; then
withval="$with_ldap_libdir"
ldaplibdir=$withval
fi
# Check whether --with-ldap-libraries or --without-ldap-libraries was given.
if test "${with_ldap_libraries+set}" = set; then
withval="$with_ldap_libraries"
ldaplibflags="-L$ldaplibdir $withval"
else
ldaplibflags="-L$ldaplibdir -lldap -llber"
fi
ldapinclude="-I$ldapincdir"
ldapbuild=yes
VERSION=${NEO_VERSION}
# Note: in the following variable, it's important to use the absolute
# path name of the Tcl directory rather than "..": this is because
# AIX remembers this path and will attempt to use it at run-time to look
# up the Tcl library.
if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
NEO_BUILD_LIB_SPEC="-L`pwd` -lldaptcl${VERSION}"
NEO_LIB_SPEC="-L${exec_prefix}/lib -lldaptcl${VERSION}"
else
NEO_BUILD_LIB_SPEC="-L`pwd` -lldaptcl`echo ${VERSION} | tr -d .`"
NEO_LIB_SPEC="-L${exec_prefix}/lib -lldaptcl`echo ${VERSION} | tr -d .`"
fi
trap '' 1 2 15
cat > confcache <<\EOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs. It is not useful on other systems.
# If it contains results you don't want to keep, you may remove or edit it.
#
# By default, configure uses ./config.cache as the cache file,
# creating it if it does not exist already. You can give configure
# the --cache-file=FILE option to use a different cache file; that is
# what configure does when it calls configure scripts in
# subdirectories, so they share the cache.
# Giving --cache-file=/dev/null disables caching, for debugging configure.
# config.status only pays attention to the cache file if you give it the
# --recheck option to rerun configure.
#
EOF
# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, don't put newlines in cache variables' values.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(set) 2>&1 |
case `(ac_space=' '; set | grep ac_space) 2>&1` in
*ac_space=\ *)
# `set' does not quote correctly, so add quotes (double-quote substitution
# turns \\\\ into \\, and sed turns \\ into \).
sed -n \
-e "s/'/'\\\\''/g" \
-e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
;;
*)
# `set' quotes correctly as required by POSIX, so do not add quotes.
sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
;;
esac >> confcache
if cmp -s $cache_file confcache; then
:
else
if test -w $cache_file; then
echo "updating cache $cache_file"
cat confcache > $cache_file
else
echo "not updating unwritable cache $cache_file"
fi
fi
rm -f confcache
trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
# Any assignment to VPATH causes Sun make to only execute
# the first set of double-colon rules, so remove it if not needed.
# If there is a colon in the path, we need to keep it.
if test "x$srcdir" = x.; then
ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
fi
trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
# Transform confdefs.h into DEFS.
# Protect against shell expansion while executing Makefile rules.
# Protect against Makefile macro expansion.
cat > conftest.defs <<\EOF
s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g
s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g
s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs
# Without the "./", some shells look in PATH for config.status.
: ${CONFIG_STATUS=./config.status}
echo creating $CONFIG_STATUS
rm -f $CONFIG_STATUS
cat > $CONFIG_STATUS <<EOF
#! /bin/sh
# Generated automatically by configure.
# Run this file to recreate the current configuration.
# This directory was configured as follows,
# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
#
# $0 $ac_configure_args
#
# Compiler output produced by configure, useful for debugging
# configure, is in ./config.log if it exists.
ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
for ac_option
do
case "\$ac_option" in
-recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
-version | --version | --versio | --versi | --vers | --ver | --ve | --v)
echo "$CONFIG_STATUS generated by autoconf version 2.13"
exit 0 ;;
-help | --help | --hel | --he | --h)
echo "\$ac_cs_usage"; exit 0 ;;
*) echo "\$ac_cs_usage"; exit 1 ;;
esac
done
ac_given_srcdir=$srcdir
ac_given_INSTALL="$INSTALL"
trap 'rm -fr `echo "Makefile pkgIndex.tcl" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
EOF
cat >> $CONFIG_STATUS <<EOF
# Protect against being on the right side of a sed subst in config.status.
sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
$ac_vpsub
$extrasub
s%@SHELL@%$SHELL%g
s%@CFLAGS@%$CFLAGS%g
s%@CPPFLAGS@%$CPPFLAGS%g
s%@CXXFLAGS@%$CXXFLAGS%g
s%@FFLAGS@%$FFLAGS%g
s%@DEFS@%$DEFS%g
s%@LDFLAGS@%$LDFLAGS%g
s%@LIBS@%$LIBS%g
s%@exec_prefix@%$exec_prefix%g
s%@prefix@%$prefix%g
s%@program_transform_name@%$program_transform_name%g
s%@bindir@%$bindir%g
s%@sbindir@%$sbindir%g
s%@libexecdir@%$libexecdir%g
s%@datadir@%$datadir%g
s%@sysconfdir@%$sysconfdir%g
s%@sharedstatedir@%$sharedstatedir%g
s%@localstatedir@%$localstatedir%g
s%@libdir@%$libdir%g
s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
s%@CC@%$CC%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@RANLIB@%$RANLIB%g
s%@TK_LIBS@%$TK_LIBS%g
s%@TK_LIB_SPEC@%$TK_LIB_SPEC%g
s%@TK_XINCLUDES@%$TK_XINCLUDES%g
s%@TK_VERSION@%$TK_VERSION%g
s%@TKX_LIB_SPEC@%$TKX_LIB_SPEC%g
s%@LDAPWISH@%$LDAPWISH%g
s%@ldaplibflags@%$ldaplibflags%g
s%@ldapinclude@%$ldapinclude%g
s%@ldapbuild@%$ldapbuild%g
s%@ldapdir@%$ldapdir%g
s%@ldapincdir@%$ldapincdir%g
s%@DL_LIBS@%$DL_LIBS%g
s%@LD_FLAGS@%$LD_FLAGS%g
s%@MATH_LIBS@%$MATH_LIBS%g
s%@MAKE_LIB@%$MAKE_LIB%g
s%@SHLIB_CFLAGS@%$SHLIB_CFLAGS%g
s%@SHLIB_LD@%$SHLIB_LD%g
s%@SHLIB_LD_LIBS@%$SHLIB_LD_LIBS%g
s%@SHLIB_SUFFIX@%$SHLIB_SUFFIX%g
s%@SHLIB_VERSION@%$SHLIB_VERSION%g
s%@TCLX_TOP_DIR@%$TCLX_TOP_DIR%g
s%@TCLX_TCL_DIR@%$TCLX_TCL_DIR%g
s%@TCLX_LIB_SPEC@%$TCLX_LIB_SPEC%g
s%@ITCL_LIB_SPEC@%$ITCL_LIB_SPEC%g
s%@TCL_LIBS@%$TCL_LIBS%g
s%@TCL_SRC_DIR@%$TCL_SRC_DIR%g
s%@TCL_BIN_DIR@%$TCL_BIN_DIR%g
s%@TCL_LIB_SPEC@%$TCL_LIB_SPEC%g
s%@TCL_LD_SEARCH_FLAGS@%$TCL_LD_SEARCH_FLAGS%g
s%@TCL_LIB_HNAME@%$TCL_LIB_HNAME%g
s%@TCL_VERSION@%$TCL_VERSION%g
s%@NEO_BUILD_LIB_SPEC@%$NEO_BUILD_LIB_SPEC%g
s%@NEO_LD_SEARCH_FLAGS@%$NEO_LD_SEARCH_FLAGS%g
s%@NEO_SHARED_LIB_FILE@%$NEO_SHARED_LIB_FILE%g
s%@NEO_UNSHARED_LIB_FILE@%$NEO_UNSHARED_LIB_FILE%g
s%@NEO_LIB_FILE@%$NEO_LIB_FILE%g
s%@NEO_LIB_SPEC@%$NEO_LIB_SPEC%g
s%@NEO_MAJOR_VERSION@%$NEO_MAJOR_VERSION%g
s%@NEO_MINOR_VERSION@%$NEO_MINOR_VERSION%g
s%@NEO_SHLIB_CFLAGS@%$NEO_SHLIB_CFLAGS%g
s%@NEO_VERSION@%$NEO_VERSION%g
CEOF
EOF
cat >> $CONFIG_STATUS <<\EOF
# Split the substitutions into bite-sized pieces for seds with
# small command number limits, like on Digital OSF/1 and HP-UX.
ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
ac_file=1 # Number of current file.
ac_beg=1 # First line for current file.
ac_end=$ac_max_sed_cmds # Line after last line for current file.
ac_more_lines=:
ac_sed_cmds=""
while $ac_more_lines; do
if test $ac_beg -gt 1; then
sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
else
sed "${ac_end}q" conftest.subs > conftest.s$ac_file
fi
if test ! -s conftest.s$ac_file; then
ac_more_lines=false
rm -f conftest.s$ac_file
else
if test -z "$ac_sed_cmds"; then
ac_sed_cmds="sed -f conftest.s$ac_file"
else
ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
fi
ac_file=`expr $ac_file + 1`
ac_beg=$ac_end
ac_end=`expr $ac_end + $ac_max_sed_cmds`
fi
done
if test -z "$ac_sed_cmds"; then
ac_sed_cmds=cat
fi
EOF
cat >> $CONFIG_STATUS <<EOF
CONFIG_FILES=\${CONFIG_FILES-"Makefile pkgIndex.tcl"}
EOF
cat >> $CONFIG_STATUS <<\EOF
for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
# Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
case "$ac_file" in
*:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
*) ac_file_in="${ac_file}.in" ;;
esac
# Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
# Remove last slash and all that follows it. Not all systems have dirname.
ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
# The file is in a subdirectory.
test ! -d "$ac_dir" && mkdir "$ac_dir"
ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
# A "../" for each directory in $ac_dir_suffix.
ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
else
ac_dir_suffix= ac_dots=
fi
case "$ac_given_srcdir" in
.) srcdir=.
if test -z "$ac_dots"; then top_srcdir=.
else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
/*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
*) # Relative path.
srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
top_srcdir="$ac_dots$ac_given_srcdir" ;;
esac
case "$ac_given_INSTALL" in
[/$]*) INSTALL="$ac_given_INSTALL" ;;
*) INSTALL="$ac_dots$ac_given_INSTALL" ;;
esac
echo creating "$ac_file"
rm -f "$ac_file"
configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
case "$ac_file" in
*Makefile*) ac_comsub="1i\\
# $configure_input" ;;
*) ac_comsub= ;;
esac
ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
sed -e "$ac_comsub
s%@configure_input@%$configure_input%g
s%@srcdir@%$srcdir%g
s%@top_srcdir@%$top_srcdir%g
s%@INSTALL@%$INSTALL%g
" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
fi; done
rm -f conftest.s*
EOF
cat >> $CONFIG_STATUS <<EOF
EOF
cat >> $CONFIG_STATUS <<\EOF
exit 0
EOF
chmod +x $CONFIG_STATUS
rm -fr confdefs* $ac_clean_files
test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
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.
AC_INIT(neoXldap.c)
# $OpenLDAP$
NEO_VERSION=2.0
NEO_MAJOR_VERSION=2
NEO_MINOR_VERSION=0
VERSION=${NEO_VERSION}
if test "${prefix}" = "NONE"; then
prefix=/usr/local
fi
if test "${exec_prefix}" = "NONE"; then
exec_prefix=$prefix
fi
AC_ARG_ENABLE(gcc, [ --enable-gcc allow use of gcc if available],
[neo_ok=$enableval], [neo_ok=no])
if test "$neo_ok" = "yes"; then
AC_PROG_CC
else
CC=${CC-cc}
AC_SUBST(CC)
fi
AC_PROG_INSTALL(install-sh)
AC_PROG_RANLIB
if test ! -f $exec_prefix/lib/tclConfig.sh
then
AC_MSG_ERROR(Tcl must be installed first)
fi
. $exec_prefix/lib/tclConfig.sh
if test ! -f $exec_prefix/lib/tclxConfig.sh
then
AC_MSG_ERROR(Extended Tcl must be installed first)
fi
. $exec_prefix/lib/tclxConfig.sh
#--------------------------------------------------------------------
# See if there was a command-line option for where Tk is; if
# not, assume that its top-level directory is a sibling of ours.
#--------------------------------------------------------------------
AC_ARG_WITH(tk, [ --with-tk=DIR use Tk 8.0 binaries from DIR],
, with_tk=yes)
case "$with_tk" in
yes)
if test -f $exec_prefix/lib/tkConfig.sh -a $exec_prefix/lib/tkxConfig.sh
then
:
else
AC_MSG_ERROR(Tk does not appear to be installed at $exec_prefix)
fi
;;
no) ;;
*) AC_MSG_ERROR(Tk cannot be specified and must be in $exec_prefix)
;;
esac
AC_ARG_WITH(x, [ --without-x do not build/install ldapwish])
if test "$with_x" = "no"
then
with_tk=no
fi
if test "$with_tk" != "no"
then
LDAPWISH=ldapwish
. $exec_prefix/lib/tkConfig.sh
. $exec_prefix/lib/tkxConfig.sh
fi
AC_SUBST(TK_LIBS)
AC_SUBST(TK_LIB_SPEC)
AC_SUBST(TK_XINCLUDES)
AC_SUBST(TK_VERSION)
AC_SUBST(TKX_LIB_SPEC)
AC_SUBST(LDAPWISH)
#--------------------------------------------------------------------
# Read in configuration information generated by Tcl for shared
# libraries, and arrange for it to be substituted into our
# Makefile.
#--------------------------------------------------------------------
CC=$TCL_CC
SHLIB_CFLAGS=$TCL_SHLIB_CFLAGS
SHLIB_LD=$TCL_SHLIB_LD
SHLIB_LD_LIBS=$TCL_SHLIB_LD_LIBS
SHLIB_SUFFIX=$TCL_SHLIB_SUFFIX
SHLIB_VERSION=$TCL_SHLIB_VERSION
DL_LIBS=$TCL_DL_LIBS
LD_FLAGS=$TCL_LD_FLAGS
NEO_LD_SEARCH_FLAGS=$TCL_LD_SEARCH_FLAGS
eval "NEO_SHARED_LIB_FILE=libldaptcl${TCL_SHARED_LIB_SUFFIX}"
eval "NEO_UNSHARED_LIB_FILE=libldaptcl${TCL_UNSHARED_LIB_SUFFIX}"
#--------------------------------------------------------------------
# The statements below define a collection of symbols related to
# building libldap as a shared library instead of a static library.
#--------------------------------------------------------------------
# Warning: in order to use the following code for libldap and libdb versions,
# the VERSION shell variable is modified, and then is restored after.
AC_ARG_ENABLE(shared,
[ --enable-shared build libldaptcl as a shared library],
[ok=$enableval], [ok=no])
if test "$ok" = "yes" -a "${SHLIB_SUFFIX}" != ""; then
NEO_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
eval "NEO_LIB_FILE=libldaptcl${TCL_SHARED_LIB_SUFFIX}"
MAKE_LIB="\${SHLIB_LD} $TCL_LIB_HNAME -o ${NEO_LIB_FILE} \${OBJS} \${LDAP_LIBFLAGS}"
RANLIB=":"
else
NEO_SHLIB_CFLAGS=""
eval "NEO_LIB_FILE=libldaptcl${TCL_UNSHARED_LIB_SUFFIX}"
MAKE_LIB="ar cr ${NEO_LIB_FILE} \${OBJS}"
fi
AC_ARG_WITH(ldap, [ --with-ldap=<dir> common parent of ldap include and lib dirs],
[neo_ldap=$withval
case $withval in
yes) ldapdir=/usr/local
;;
no) ;;
*) ldapdir=$withval
neo_ldap=yes
;;
esac
], [
neo_ldap=yes
ldapdir=/usr/local
])
ldapincdir=$ldapdir/include
AC_ARG_WITH(ldap-incdir, [ --with-ldap-incdir=<dir> path to ldap.h],
[ldapincdir=$withval])
ldaplibdir=$ldapdir/lib
AC_ARG_WITH(ldap-libdir, [ --with-ldap-libdir=<dir> path to ldap and lber libs],
[ldaplibdir=$withval])
AC_ARG_WITH(ldap-libraries, [ --with-ldap-libflags=<libnames> -l flags for ldap libraries],
[ldaplibflags="-L$ldaplibdir $withval"],
[ldaplibflags="-L$ldaplibdir -lldap -llber"])
ldapinclude="-I$ldapincdir"
ldapbuild=yes
AC_SUBST(ldaplibflags)
AC_SUBST(ldapinclude)
AC_SUBST(ldapbuild)
AC_SUBST(ldapdir)
AC_SUBST(ldapincdir)
VERSION=${NEO_VERSION}
# Note: in the following variable, it's important to use the absolute
# path name of the Tcl directory rather than "..": this is because
# AIX remembers this path and will attempt to use it at run-time to look
# up the Tcl library.
if test "${TCL_LIB_VERSIONS_OK}" = "ok"; then
NEO_BUILD_LIB_SPEC="-L`pwd` -lldaptcl${VERSION}"
NEO_LIB_SPEC="-L${exec_prefix}/lib -lldaptcl${VERSION}"
else
NEO_BUILD_LIB_SPEC="-L`pwd` -lldaptcl`echo ${VERSION} | tr -d .`"
NEO_LIB_SPEC="-L${exec_prefix}/lib -lldaptcl`echo ${VERSION} | tr -d .`"
fi
AC_SUBST(CC)
AC_SUBST(LIBS)
AC_SUBST(DL_LIBS)
AC_SUBST(LD_FLAGS)
AC_SUBST(MATH_LIBS)
AC_SUBST(MAKE_LIB)
AC_SUBST(SHLIB_CFLAGS)
AC_SUBST(SHLIB_LD)
AC_SUBST(SHLIB_LD_LIBS)
AC_SUBST(SHLIB_SUFFIX)
AC_SUBST(SHLIB_VERSION)
AC_SUBST(TCLX_TOP_DIR)
AC_SUBST(TCLX_TCL_DIR)
AC_SUBST(TCLX_LIB_SPEC)
AC_SUBST(ITCL_LIB_SPEC)
AC_SUBST(TCL_LIBS)
AC_SUBST(TCL_SRC_DIR)
AC_SUBST(TCL_BIN_DIR)
AC_SUBST(TCL_LIB_SPEC)
AC_SUBST(TCL_LD_SEARCH_FLAGS)
AC_SUBST(TCL_LIB_HNAME)
AC_SUBST(TCL_SRC_DIR)
AC_SUBST(TCL_VERSION)
AC_SUBST(NEO_BUILD_LIB_SPEC)
AC_SUBST(NEO_LD_SEARCH_FLAGS)
AC_SUBST(NEO_SHARED_LIB_FILE)
AC_SUBST(NEO_UNSHARED_LIB_FILE)
AC_SUBST(NEO_LIB_FILE)
AC_SUBST(NEO_LIB_SPEC)
AC_SUBST(NEO_MAJOR_VERSION)
AC_SUBST(NEO_MINOR_VERSION)
AC_SUBST(NEO_SHLIB_CFLAGS)
AC_SUBST(NEO_VERSION)
dnl AC_SUBST(XINCLUDES)
dnl AC_SUBST(XLIBSW)
AC_OUTPUT(Makefile pkgIndex.tcl)
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5; it is not part of GNU.
#
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
instcmd="$mvprog"
chmodcmd=""
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
fi
# Make a temp file name in the proper directory.
dstdir=`dirname $dst`
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp
# and set any options; do chmod last to preserve setuid bits
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi
# Now rename the file to the real destination.
$doit $rmcmd $dst
$doit $mvcmd $dsttmp $dst
exit 0
'\"
'\" Copyright (c) 1998 NeoSoft, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
.so man.macros
.TH ldap n "" Ldap "Ldap Tcl Extension"
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
ldap \- connect to and query an LDAP server
.SH SYNOPSIS
\fBldap \fBopen \fR \fIcommand\fR \fIhostlist\fR
.br
\fBldap \fBinit \fR \fIcommand\fR \fIhostlist\fR ?protocol_version [2|3]?
.br
\fBldap \fBexplode ?-nonames|-list?\fR \fIdn\fR
.br
\fIcommand \fBsubcommand \fIoptions ...\fR
.BE
.SH OVERVIEW
.PP
A new command by the name of \fIcommand\fR will be created to access
the LDAP database at \fIhostlist\fR. \fIhostlist\fR may contain elements
of the format \fBhost:port\fR if a port other than the default LDAP port
of 389 is required. The LDAP library will attempt to connect to each
host in turn until it succeeds or exhausts the list.
.PP
The \fBexplode\fR form provides a means (via ldap_explode(3)) to explode a DN
into its component parts. \fB-nonames\fR strips off the attribute names,
and -list returns a list suitable for \fBarray set\fR.
.PP
Finally, the last form, described in more detail below, refers genericly
to how the command created by the first two examples is used.
.SH DESCRIPTION
The Lightweight Directory Access Protocol provides TCP/IP access to
X.500 directory services and/or to a stand-alone LDAP server.
This code provides a Tcl interface to the
Lightweight Directory Access Protocol package using the Netscape
Software Development Kit. It can also be used with the freely
redistributable University of
Michigan (http://www.umich.edu/~rsug/ldap) version by defining the
UMICH_LDAP macro during compilation.
.SH CONNECTING TO AN LDAP SERVER
To create an ldap interface entity, we use the "ldap" command.
ldap open foo foo.bar.com
This opens a connection to a LDAP server on foo.bar.com, and makes
a new Tcl command, foo, through which we will manipulate the interface
and make queries to the remote LDAP server.
ldap init foo foo.bar.com
Same as above, foo is created, but for "init", opening the connection is
deferred until we actually try to do something.
The init command also allows some optional values to be set for the connection.
Currently, the only useful option is \fBprotocol_version\fR which take a
single argument to specify to use LDAP protocol 2 or 3. This may be required
when connecting to older LDAP server.
For the purposes of this example, we're going to assume that "foo" is the
command created by opening a connection using "ldap open".
.SH BINDING
After a connection is made to an LDAP server, an LDAP bind operation must
be performed before other operations can be attempted over the connection.
Both simple authentication and kerberos authentication are available.
LDAP version 3 supports many new "SSL"-style authentication and encryption
systems, which are not currently supported by the OpenLDAP v1.2 server, and
hence by this interface package.
Currently simple and kerberos-based authentication, are supported.
To use LDAP and still have reasonable security in a networked,
Internet/Intranet environment, secure shell can be used to setup
secure, encrypted connections between client machines and the LDAP
server, and between the LDAP server and any replica or slave servers
that might be used.
To perform the LDAP "bind" operation:
foo bind simple dn password
foo bind kerberos_ldap
foo bind kerberos_dsa
foo bind kerberos_both
It either returns nothing (success), or a Tcl error with appropriate error
text.
For example,
foo bind simple "cn=Manager,o=NeoSoft Inc,c=us" "secret"
If you attempt to bind with one of the kerberos authentication types
described above and your LDAP library was not built with KERBEROS
defined, you will get an unknown auth type error.
To unbind an LDAP connection previously bound with "bind":
foo unbind
Note that unbinding also deletes the command (\fBfoo\fR in this case).
Deleting the command has the same affect.
The ability of the library to callback to the client, enabling re-binding
while following referrals, is not currently supported.
.SH DELETING OBJECTS
To delete an object in the LDAP database, use
foo delete dn
To rename an object to another relative distinguished name, use
foo rename_rdn dn rdn
To rename an object to another relative distinguished name, leaving
the old entry as some kind of attribute (FIX: not sure if this is
right or how it works)
foo modify_rdn dn rdn
.SH ADDING NEW OBJECTS
foo add dn attributePairList
This creates a new distinguished name and defines zero or more attributes.
"attributePairList" is a list of key-value pairs, the same as would
be returned by "array get" if an array had been set up containing the
key-value pairs.
foo add "cn=karl, ou=People, o=NeoSoft Inc, c=US" {cn karl ...}
Some directory servers and/or their client SDKs will automatically
add the leaf attribute value for you.
Here is a more precise description of how an attributePairList looks:
{cn {karl {Karl Lehenbauer}} telephone 713-968-5800}
Note here that two cn values, "karl" and "Karl Lehenbauer", are added.
Is it an error to write:
{cn {Karl Lehenbauer}}
Which adds two cn values, "Karl" and "Lehenbauer", when the intention
was to give a single cn value of "Karl Lehenbauer". In real life, one
finds oneself making prodigous use of the \fBlist\fR command rather than
typing hard-coded lists.
We have noticed that the Netscape server will automatically add the
left-most rdn portion of the DN (ie. cn=karl), whereas the University
of Michigan and OpenLDAP 1.2 versions do not.
.SH ADDING, DELETING, AND REPLACING OBJECT ATTRIBUTES
You can have multiple values for a given attribute in an LDAP object.
These are represented in search results, through the Tcl interface,
as a list.
foo add_attributes dn attributePairList
This adds key-value pairs to an existing DN. If an attribute being
added already exists, the new value will be appended to the list.
If a particular value being added to an attribute already exists in
the object a Tcl error is raised.
foo replace_attributes dn attributePairList
This replaces the specified attributes in an existing DN, leaving
unnamed ones untouched. Any previous values for the supplied attributes
(if any) are discarded.
foo delete_attributes dn attributePairList
This deletes attributes in the list. If an attribute "foo" has the
value list {bar snap}, and you delete using the attributePairList "foo bar",
"foo" will still have "snap".
If you provide an empty string ("") for the value list,
the entire attribute will be deleted.
In Ldaptcl version 2.0, multiple operations may be combined into a single
transaction, ie. as in:
foo add_attributes dn attributePairList replace attributePairList \
delete attributePairList
.SH SEARCHING
The Tcl interface to searching takes a control array, which contains
a couple of mandatory key-value pairs, and can contain a number of
optional key-value pairs as well, for controlling the search, a
destination array, into which the specified attributes (or all attributes
of matching DNs if none are specified) and values are stored.
The "code" part is executed repeatedly, once for each DN matching the
search criteria.
.nf
foo search controlArray destArray code
Using data in the control array, a search is performed of the
LDAP server opened when foo was created. Possible elements
of the control array are enumerated blow.
controlArray(base) is the DN being searched from. (required)
controlArray(filter) contains the search criteria. (required)
controlArray(scope) must be "base", "one_level", or "subtree".
If not specified, scope defaults to "subtree".
controlArray(deref) must be "never", "search", "find", or "always"
If not specified, deref defaults to "never"
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).
.fi
For each matching record, destArray is populated with none,
some or all attribute-value pairs as determined by the request and
access control lists on the server.
Note: There are some additional parameters that can be set, such as
how long the synchronous version of the routines should wait before
timing out, the interfaces for which are not available in the current
version.
.SH COMPARE
foo compare dn attribute value
Interface to the ldap_compare_s() command.
Compares the value of \fIattribute\fR in the object at \fIdn\fR to the
\fIvalue\fR given in the command line. Returns an error if \fIdn\fR
does not exist. Otherwise, a
.SH CACHING (Note: Netscape clients do not have caching interfaces).
The UMich and OpenLDAP client libraries offers the client application fairly
fine-grained control of caching of results retrieved from searches,
offering significant performance improvement and reduced
network traffic.
By default, the cache is disabled.
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 for caching, in bytes.
If maxmem is 0, the cache size is restricted only by the timeout.
foo cache disable
...temporarily inhibits use of the cache (while disabled, new requests
are not cached and the cache is not checked when returning results).
Disabling the cache does not delete its contents.
foo cache destroy
...turns off caching and completely removes the cache from memory.
foo cache flush
...deletes the entire cache contents, but does not affect
whether or not the cache is being used.
foo cache uncache dn
...removes from the cache all request results that make reference
to the specified DN.
This should be used, for example, after doing an add_attributes,
delete_attributes, or replace_attributes (ldap_modify(3))
involving the requested DN. Generally this should not be needed,
as the Tcl interface automatically performs this operation on
any dn that is modified (add,replace,delete) while caching is
enabled.
foo cache no_errors
...suppresses caching of any requests that result in an error.
foo cache size_errors
...suppresses caching of any requests that result in an error,
except for requests resulting in "sizelimit exceeded", which
are cached. This is the default.
foo cache all_errors
...enables caching of all requests, including those that result
in errors.
.SH IMPLEMENTATION DECISIONS
Because we used the new "Tcl object" C interfaces, this package only works
with Tcl 8.0 or above.
This package interfaces with the University of Michigan LDAP protocol
package, version 3.3, and OpenLDAP version 1.2, both of which are
implementations of version 2 of the LDAP protocol.
Although an LDAP client (or server) could be written in native Tcl 8.0,
as Tcl 8.0 and above can do binary I/O, and Tcl 8 and above have strings
that are fully eight-bit clean, for a first implementation, to minimize
compatibility problems, we created a C interface to the UMich LDAP library.
A native Tcl implementation would be cool because we could bring the receiving
of messages into the normal Tcl event loop and run the LDAP interface fully
asynchronous.
This implementation is blocking, and blocking only. That is to say that
the Tcl event loop is frozen while the ldap routines are waiting on data.
This could be fixed either by recoding all of the I/O in the LDAP library
to use Tcl's I/O system instead, or by simply coding the LDAP interface in
native Tcl, as mentioned above.
Another advantage of coding in high-level Tcl, of course, is that the
client would immediately be cross-platform to Windows and the Mac, as
well as Unix.
Binary data is not currently supported. It will probably be trivial to
add, we just haven't dug into it yet.
.SH FOR MORE INFORMATION
This document principally describes how to use our Tcl interface to the
LDAP library works.
For more information on LDAP and the University of Michigan LDAP package,
please visit the website mentioned above. The package includes substantial
documentation in the form of UNIX manual pages, a SLAPD/SLURPD guide
in Adobe Portable Document Format (pdf), and a number of Internet RFCs
related to LDAP services.
.SH AUTHORS
It was written by Karl Lehenbauer, of NeoSoft, Inc., in August and
September of 1997. Ldap explode, and numerous bug fixes and extensions
by Randy Kunkee, also of NeoSoft, Inc., in 1998-1999.
.SH KEYWORDS
element, join, list, separator
.SH BUGS
The \fBldap init\fR syntax fails to return anything useful. Use
\fBldap open\fR instead.
\fBPackage require Ldaptcl\fR won't work unless the ldap and lber libraries
are also shared, and ldaptcl.so is itself created with the correct flags
(eg. -R for Solaris). In short there's a lot of details to make this part
work, but it should work out of the box for Solaris. Other systems may
require that LD_LIBRARY_PATH or other appropraite environment variables
be set at build and/or runtime.
An asynchronous interface should be provided with callbacks.
We have never tested Kerberos authentication.
It does not tolerate some illegal operations very well.
It is possible to create empty attributes, ie. attributes which are present
but have no value. This is done by deleting the attribute values rather
than, eg. "foo delete_attributes dn {telephone {}}" which would delete
the telephone attribute altogether. A search for presence of the attribute
may return an object, and yet it may have no value. This interface presents
such an object as not having the attribute at all (ie. you cannot tell).
The Netscape SDK does this for you, so this makes the behavior consistent
when using UMICH_LDAP.
\--enable-netscape configuration support has not been tested and probably
has bugs.
#
# ldaperr.tcl: scan ldap.h for error return codes for initializing
# errorCode table.
#
proc genstrings {path} {
set fp [open $path]
while {[gets $fp line] != -1 &&
![string match "#define LDAP_SUCCESS*" $line]} { }
puts "/* This file automatically generated, hand edit at your own risk! */"
puts -nonewline "char *ldaptclerrorcode\[\] = {
NULL"
while {[gets $fp line] != -1} {
if {[clength $line] == 0 || [ctype space $line]} continue
if {[string match *typedef* $line]} break
if {![string match #define* $line]} continue
if {![string match "#define LDAP_*" $line]} continue
if {[string match "*LDAP_RANGE*" $line]} continue
if {[string match "*LDAP_API_RESULT*" $line]} continue
if {[string match {*\\} $line]} {
append line [gets $fp]
}
lassign $line define macro value
set ldap_errcode($macro) $value
}
#parray ldap_errcode
foreach i [array names ldap_errcode] {
set value $ldap_errcode($i)
#puts stderr "checking $value"
if [regexp {^[A-Z_]} $value] {
if [info exists ldap_errcode($value)] {
set value $ldap_errcode($value)
set ldap_errcode($i) $value
}
}
set ldap_errname($value) $i
}
set lasterr 0
foreach value [lsort -integer [array names ldap_errname]] {
incr lasterr
while {$lasterr < $value} {
puts -nonewline ",\n\tNULL"
incr lasterr
}
puts -nonewline ",\n\t\"$ldap_errname($value)\""
}
puts "\n};"
puts "#define LDAPTCL_MAXERR\t$value"
}
#cmdtrace on
if !$tcl_interactive {
genstrings [lindex $argv 0]
}
'\" The definitions below are for supplemental macros used in Tcl/Tk
'\" manual entries.
'\"
'\" .AP type name in/out ?indent?
'\" Start paragraph describing an argument to a library procedure.
'\" type is type of argument (int, etc.), in/out is either "in", "out",
'\" or "in/out" to describe whether procedure reads or modifies arg,
'\" and indent is equivalent to second arg of .IP (shouldn't ever be
'\" needed; use .AS below instead)
'\"
'\" .AS ?type? ?name?
'\" Give maximum sizes of arguments for setting tab stops. Type and
'\" name are examples of largest possible arguments that will be passed
'\" to .AP later. If args are omitted, default tab stops are used.
'\"
'\" .BS
'\" Start box enclosure. From here until next .BE, everything will be
'\" enclosed in one large box.
'\"
'\" .BE
'\" End of box enclosure.
'\"
'\" .CS
'\" Begin code excerpt.
'\"
'\" .CE
'\" End code excerpt.
'\"
'\" .VS ?version? ?br?
'\" Begin vertical sidebar, for use in marking newly-changed parts
'\" of man pages. The first argument is ignored and used for recording
'\" the version when the .VS was added, so that the sidebars can be
'\" found and removed when they reach a certain age. If another argument
'\" is present, then a line break is forced before starting the sidebar.
'\"
'\" .VE
'\" End of vertical sidebar.
'\"
'\" .DS
'\" Begin an indented unfilled display.
'\"
'\" .DE
'\" End of indented unfilled display.
'\"
'\" .SO
'\" Start of list of standard options for a Tk widget. The
'\" options follow on successive lines, in four columns separated
'\" by tabs.
'\"
'\" .SE
'\" End of list of standard options for a Tk widget.
'\"
'\" .OP cmdName dbName dbClass
'\" Start of description of a specific option. cmdName gives the
'\" option's name as specified in the class command, dbName gives
'\" the option's name in the option database, and dbClass gives
'\" the option's class in the option database.
'\"
'\" .UL arg1 arg2
'\" Print arg1 underlined, then print arg2 normally.
'\"
'\" SCCS: @(#) man.macros 1.9 97/08/22 18:50:59
'\"
'\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
.nr ^l \n(.l
.ad b
'\" # Start an argument description
.de AP
.ie !"\\$4"" .TP \\$4
.el \{\
. ie !"\\$2"" .TP \\n()Cu
. el .TP 15
.\}
.ie !"\\$3"" \{\
.ta \\n()Au \\n()Bu
\&\\$1 \\fI\\$2\\fP (\\$3)
.\".b
.\}
.el \{\
.br
.ie !"\\$2"" \{\
\&\\$1 \\fI\\$2\\fP
.\}
.el \{\
\&\\fI\\$1\\fP
.\}
.\}
..
'\" # define tabbing values for .AP
.de AS
.nr )A 10n
.if !"\\$1"" .nr )A \\w'\\$1'u+3n
.nr )B \\n()Au+15n
.\"
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
.nr )C \\n()Bu+\\w'(in/out)'u+2n
..
.AS Tcl_Interp Tcl_CreateInterp in/out
'\" # BS - start boxed text
'\" # ^y = starting y location
'\" # ^b = 1
.de BS
.br
.mk ^y
.nr ^b 1u
.if n .nf
.if n .ti 0
.if n \l'\\n(.lu\(ul'
.if n .fi
..
'\" # BE - end boxed text (draw box now)
.de BE
.nf
.ti 0
.mk ^t
.ie n \l'\\n(^lu\(ul'
.el \{\
.\" Draw four-sided box normally, but don't draw top of
.\" box if the box started on an earlier page.
.ie !\\n(^b-1 \{\
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.el \}\
\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.\}
.fi
.br
.nr ^b 0
..
'\" # VS - start vertical sidebar
'\" # ^Y = starting y location
'\" # ^v = 1 (for troff; for nroff this doesn't matter)
.de VS
.if !"\\$2"" .br
.mk ^Y
.ie n 'mc \s12\(br\s0
.el .nr ^v 1u
..
'\" # VE - end of vertical sidebar
.de VE
.ie n 'mc
.el \{\
.ev 2
.nf
.ti 0
.mk ^t
\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
.sp -1
.fi
.ev
.\}
.nr ^v 0
..
'\" # Special macro to handle page bottom: finish off current
'\" # box/sidebar if in box/sidebar mode, then invoked standard
'\" # page bottom macro.
.de ^B
.ev 2
'ti 0
'nf
.mk ^t
.if \\n(^b \{\
.\" Draw three-sided box if this is the box's first page,
.\" draw two sides but no top otherwise.
.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.\}
.if \\n(^v \{\
.nr ^x \\n(^tu+1v-\\n(^Yu
\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
.\}
.bp
'fi
.ev
.if \\n(^b \{\
.mk ^y
.nr ^b 2
.\}
.if \\n(^v \{\
.mk ^Y
.\}
..
'\" # DS - begin display
.de DS
.RS
.nf
.sp
..
'\" # DE - end display
.de DE
.fi
.RE
.sp
..
'\" # SO - start of list of standard options
.de SO
.SH "STANDARD OPTIONS"
.LP
.nf
.ta 4c 8c 12c
.ft B
..
'\" # SE - end of list of standard options
.de SE
.fi
.ft R
.LP
See the \\fBoptions\\fR manual entry for details on the standard options.
..
'\" # OP - start of full description for a single option
.de OP
.LP
.nf
.ta 4c
Command-Line Name: \\fB\\$1\\fR
Database Name: \\fB\\$2\\fR
Database Class: \\fB\\$3\\fR
.fi
.IP
..
'\" # CS - begin code excerpt
.de CS
.RS
.nf
.ta .25i .5i .75i 1i
..
'\" # CE - end code excerpt
.de CE
.fi
.RE
..
.de UL
\\$1\l'|0\(ul'\\$2
..
/*
* NeoSoft Tcl client extensions to Lightweight Directory Access Protocol.
*
* Copyright (c) 1998-1999 NeoSoft, Inc.
* All Rights Reserved.
*
* This software may be used, modified, copied, distributed, and sold,
* in both source and binary form provided that these copyrights are
* retained and their terms are followed.
*
* Under no circumstances are the authors or NeoSoft Inc. responsible
* for the proper functioning of this software, nor do the authors
* assume any liability for damages incurred with its use.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to NeoSoft, Inc.
*
* NeoSoft, Inc. may not be used to endorse or promote products derived
* from this software without specific prior written permission. This
* software is provided ``as is'' without express or implied warranty.
*
* Requests for permission may be sent to NeoSoft Inc, 1770 St. James Place,
* Suite 500, Houston, TX, 77056.
*
* $OpenLDAP$
*
*/
/*
* This code was originally developed by Karl Lehenbauer to work with
* Umich-3.3 LDAP. It was debugged against the Netscape LDAP server
* and their much more reliable SDK, and again backported to the
* Umich-3.3 client code. The UMICH_LDAP define is used to include
* code that will work with the Umich-3.3 LDAP, but not with Netscape's
* SDK. OpenLDAP may support some of these, but they have not been tested.
* Currently supported by Randy Kunkee (kunkee@OpenLDAP.org).
*/
/*
* 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
* checking of the strings are equal.
*/
#define STREQU(str1, str2) \
(((str1) [0] == (str2) [0]) && (strcmp (str1, str2) == 0))
#define STRNEQU(str1, str2, n) \
(((str1) [0] == (str2) [0]) && (strncmp (str1, str2, n) == 0))
/*
* The following section defines some common macros used by the rest
* of the code. It's ugly, and can use some work. This code was
* originally developed to work with Umich-3.3 LDAP. It was debugged
* against the Netscape LDAP server and the much more reliable SDK,
* and then again backported to the Umich-3.3 client code.
*/
#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
** specific (though I would hope it's value is greater than 1823).
** In OpenLDAP 2.x-devel, its 2000 + the draft number, ie 2002.
** This section is for OPENLDAP.
*/
#ifndef LDAP_API_FEATURE_X_OPENLDAP
#define ldap_memfree(p) free(p)
#endif
#ifdef LDAP_OPT_ERROR_NUMBER
#define ldap_get_lderrno(ld) (ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &lderrno), lderrno)
#else
#define ldap_get_lderrno(ld) (ld->ld_errno)
#endif
#define LDAP_ERR_STRING(ld) \
ldap_err2string(ldap_get_lderrno(ld))
#elif defined( LDAP_OPT_SIZELIMIT )
/*
** Netscape SDK w/ ldap_set_option, ldap_get_option
*/
#define LDAP_ERR_STRING(ld) \
ldap_err2string(ldap_get_lderrno(ldap))
#else
/* U-Mich/OpenLDAP 1.x API */
/* RFC-1823 w/ changes */
#define UMICH_LDAP 1
#define ldap_memfree(p) free(p)
#define ldap_ber_free(p, n) ber_free(p, n)
#define ldap_value_free_len(bvals) ber_bvecfree(bvals)
#define ldap_get_lderrno(ld) (ld->ld_errno)
#define LDAP_ERR_STRING(ld) \
ldap_err2string(ld->ld_errno)
#endif
typedef struct ldaptclobj {
LDAP *ldap;
int caching; /* flag 1/0 if caching is enabled */
long timeout; /* timeout from last cache enable */
long maxmem; /* maxmem from last cache enable */
Tcl_Obj *trapCmdObj; /* error handler */
int *traplist; /* list of errorCodes to trap */
int flags;
} LDAPTCL;
#define LDAPTCL_INTERRCODES 0x001
#include "ldaptclerr.h"
static
LDAP_SetErrorCode(LDAPTCL *ldaptcl, int code, Tcl_Interp *interp)
{
char shortbuf[16];
char *errp;
int lderrno;
if (code == -1)
code = ldap_get_lderrno(ldaptcl->ldap);
if ((ldaptcl->flags & LDAPTCL_INTERRCODES) || code > LDAPTCL_MAXERR ||
ldaptclerrorcode[code] == NULL) {
sprintf(shortbuf, "0x%03x", code);
errp = shortbuf;
} else
errp = ldaptclerrorcode[code];
Tcl_SetErrorCode(interp, errp, NULL);
if (ldaptcl->trapCmdObj) {
int *i;
Tcl_Obj *cmdObj;
if (ldaptcl->traplist != NULL) {
for (i = ldaptcl->traplist; *i && *i != code; i++)
;
if (*i == 0) return;
}
(void) Tcl_EvalObj(interp, ldaptcl->trapCmdObj);
}
}
static
LDAP_ErrorStringToCode(Tcl_Interp *interp, char *s)
{
int offset;
int code;
offset = (strncasecmp(s, "LDAP_", 5) == 0) ? 0 : 5;
for (code = 0; code < LDAPTCL_MAXERR; code++) {
if (!ldaptclerrorcode[code]) continue;
if (strcasecmp(s, ldaptclerrorcode[code]+offset) == 0)
return code;
}
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, s, " is an invalid code", (char *) NULL);
return -1;
}
/*-----------------------------------------------------------------------------
* LDAP_ProcessOneSearchResult --
*
* Process one result return from an LDAP search.
*
* Paramaters:
* o interp - Tcl interpreter; Errors are returned in result.
* o ldap - LDAP structure pointer.
* o entry - LDAP message pointer.
* o destArrayNameObj - Name of Tcl array in which to store attributes.
* o evalCodeObj - Tcl_Obj pointer to code to eval against this result.
* Returns:
* o TCL_OK if processing succeeded..
* o TCL_ERROR if an error occured, with error message in interp.
*-----------------------------------------------------------------------------
*/
int
LDAP_ProcessOneSearchResult (interp, ldap, entry, destArrayNameObj, evalCodeObj)
Tcl_Interp *interp;
LDAP *ldap;
LDAPMessage *entry;
Tcl_Obj *destArrayNameObj;
Tcl_Obj *evalCodeObj;
{
char *attributeName;
Tcl_Obj *attributeNameObj;
Tcl_Obj *attributeDataObj;
int i;
BerElement *ber;
struct berval **bvals;
char *dn;
int lderrno;
Tcl_UnsetVar (interp, Tcl_GetStringFromObj (destArrayNameObj, NULL), 0);
dn = ldap_get_dn(ldap, entry);
if (dn != NULL) {
if (Tcl_SetVar2(interp, /* set dn */
Tcl_GetStringFromObj(destArrayNameObj, NULL),
"dn",
dn,
TCL_LEAVE_ERR_MSG) == NULL)
return TCL_ERROR;
ldap_memfree(dn);
}
attributeNameObj = Tcl_NewObj();
Tcl_IncrRefCount (attributeNameObj);
/* Note that attributeName below is allocated for OL2+ libldap, so it
must be freed with ldap_memfree(). Test below is admittedly a hack.
*/
for (attributeName = ldap_first_attribute (ldap, entry, &ber);
attributeName != NULL;
attributeName = ldap_next_attribute(ldap, entry, ber)) {
bvals = ldap_get_values_len(ldap, entry, attributeName);
if (bvals != NULL) {
/* Note here that the U.of.M. ldap will return a null bvals
when the last attribute value has been deleted, but still
retains the attributeName. Even though this is documented
as an error, we ignore it to present a consistent interface
with Netscape's server
*/
attributeDataObj = Tcl_NewObj();
Tcl_SetStringObj(attributeNameObj, attributeName, -1);
#if LDAP_API_VERSION >= 2004
ldap_memfree(attributeName); /* free if newer API */
#endif
for (i = 0; bvals[i] != NULL; i++) {
Tcl_Obj *singleAttributeValueObj;
singleAttributeValueObj = Tcl_NewStringObj(bvals[i]->bv_val, bvals[i]->bv_len);
if (Tcl_ListObjAppendElement (interp,
attributeDataObj,
singleAttributeValueObj)
== TCL_ERROR) {
ber_free(ber, 0);
return TCL_ERROR;
}
}
ldap_value_free_len(bvals);
if (Tcl_ObjSetVar2 (interp,
destArrayNameObj,
attributeNameObj,
attributeDataObj,
TCL_LEAVE_ERR_MSG) == NULL) {
return TCL_ERROR;
}
}
}
Tcl_DecrRefCount (attributeNameObj);
return Tcl_EvalObj (interp, evalCodeObj);
}
/*-----------------------------------------------------------------------------
* LDAP_PerformSearch --
*
* Perform an LDAP search.
*
* Paramaters:
* o interp - Tcl interpreter; Errors are returned in result.
* o ldap - LDAP structure pointer.
* o base - Base DN from which to perform search.
* o scope - LDAP search scope, must be one of LDAP_SCOPE_BASE,
* LDAP_SCOPE_ONELEVEL, or LDAP_SCOPE_SUBTREE.
* o attrs - Pointer to array of char * pointers of desired
* attribute names, or NULL for all attributes.
* o filtpatt LDAP filter pattern.
* o value Value to get sprintf'ed into filter pattern.
* o destArrayNameObj - Name of Tcl array in which to store attributes.
* o evalCodeObj - Tcl_Obj pointer to code to eval against this result.
* Returns:
* o TCL_OK if processing succeeded..
* o TCL_ERROR if an error occured, with error message in interp.
*-----------------------------------------------------------------------------
*/
int
LDAP_PerformSearch (interp, ldaptcl, base, scope, attrs, filtpatt, value,
destArrayNameObj, evalCodeObj, timeout_p, all, sortattr)
Tcl_Interp *interp;
LDAPTCL *ldaptcl;
char *base;
int scope;
char **attrs;
char *filtpatt;
char *value;
Tcl_Obj *destArrayNameObj;
Tcl_Obj *evalCodeObj;
struct timeval *timeout_p;
int all;
char *sortattr;
{
LDAP *ldap = ldaptcl->ldap;
char filter[BUFSIZ];
int resultCode;
int errorCode;
int abandon;
int tclResult = TCL_OK;
int msgid;
LDAPMessage *resultMessage = 0;
LDAPMessage *entryMessage = 0;
char *sortKey;
int lderrno;
sprintf(filter, filtpatt, value);
fflush(stderr);
if ((msgid = ldap_search (ldap, base, scope, filter, attrs, 0)) == -1) {
Tcl_AppendResult (interp,
"LDAP start search error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, -1, interp);
return TCL_ERROR;
}
abandon = 0;
if (sortattr)
all = 1;
tclResult = TCL_OK;
while (!abandon) {
resultCode = ldap_result (ldap, msgid, all, timeout_p, &resultMessage);
if (resultCode != LDAP_RES_SEARCH_RESULT &&
resultCode != LDAP_RES_SEARCH_ENTRY)
break;
if (sortattr) {
sortKey = (strcasecmp(sortattr, "dn") == 0) ? NULL : sortattr;
ldap_sort_entries(ldap, &resultMessage, sortKey, strcasecmp);
}
entryMessage = ldap_first_entry(ldap, resultMessage);
while (entryMessage) {
tclResult = LDAP_ProcessOneSearchResult (interp,
ldap,
entryMessage,
destArrayNameObj,
evalCodeObj);
if (tclResult != TCL_OK) {
if (tclResult == TCL_CONTINUE) {
tclResult = TCL_OK;
} else if (tclResult == TCL_BREAK) {
tclResult = TCL_OK;
abandon = 1;
break;
} else if (tclResult == TCL_ERROR) {
char msg[100];
sprintf(msg, "\n (\"search\" body line %d)",
interp->errorLine);
Tcl_AddObjErrorInfo(interp, msg, -1);
abandon = 1;
break;
} else {
abandon = 1;
break;
}
}
entryMessage = ldap_next_entry(ldap, entryMessage);
}
if (resultCode == LDAP_RES_SEARCH_RESULT || all)
break;
if (resultMessage)
ldap_msgfree(resultMessage);
resultMessage = NULL;
}
if (abandon) {
if (resultMessage)
ldap_msgfree(resultMessage);
if (resultCode == LDAP_RES_SEARCH_ENTRY)
ldap_abandon(ldap, msgid);
return tclResult;
}
if (resultCode == -1) {
Tcl_ResetResult (interp);
Tcl_AppendResult (interp,
"LDAP result search error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, -1, interp);
return TCL_ERROR;
}
if ((errorCode = ldap_result2error (ldap, resultMessage, 0))
!= LDAP_SUCCESS) {
Tcl_ResetResult (interp);
Tcl_AppendResult (interp,
"LDAP search error: ",
ldap_err2string(errorCode),
(char *)NULL);
if (resultMessage)
ldap_msgfree(resultMessage);
LDAP_SetErrorCode(ldaptcl, errorCode, interp);
return TCL_ERROR;
}
if (resultMessage)
ldap_msgfree(resultMessage);
return tclResult;
}
/*-----------------------------------------------------------------------------
* NeoX_LdapTargetObjCmd --
*
* Implements the body of commands created by Neo_LdapObjCmd.
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*-----------------------------------------------------------------------------
*/
int
NeoX_LdapTargetObjCmd (clientData, interp, objc, objv)
ClientData clientData;
Tcl_Interp *interp;
int objc;
Tcl_Obj *CONST objv[];
{
char *command;
char *subCommand;
LDAPTCL *ldaptcl = (LDAPTCL *)clientData;
LDAP *ldap = ldaptcl->ldap;
char *dn;
int is_add = 0;
int is_add_or_modify = 0;
int mod_op = 0;
char *m, *s, *errmsg;
int errcode;
int tclResult;
int lderrno; /* might be used by LDAP_ERR_STRING macro */
Tcl_Obj *resultObj = Tcl_GetObjResult (interp);
if (objc < 2) {
Tcl_WrongNumArgs (interp, 1, objv, "subcommand [args...]");
return TCL_ERROR;
}
command = Tcl_GetStringFromObj (objv[0], NULL);
subCommand = Tcl_GetStringFromObj (objv[1], NULL);
/* object bind authtype name password */
if (STREQU (subCommand, "bind")) {
char *binddn;
char *passwd;
int stringLength;
char *ldap_authString;
int ldap_authInt;
if (objc != 5) {
Tcl_WrongNumArgs (interp, 2, objv, "authtype dn passwd");
return TCL_ERROR;
}
ldap_authString = Tcl_GetStringFromObj (objv[2], NULL);
if (STREQU (ldap_authString, "simple")) {
ldap_authInt = LDAP_AUTH_SIMPLE;
}
#ifdef UMICH_LDAP
else if (STREQU (ldap_authString, "kerberos_ldap")) {
ldap_authInt = LDAP_AUTH_KRBV41;
} else if (STREQU (ldap_authString, "kerberos_dsa")) {
ldap_authInt = LDAP_AUTH_KRBV42;
} else if (STREQU (ldap_authString, "kerberos_both")) {
ldap_authInt = LDAP_AUTH_KRBV4;
}
#endif
else {
Tcl_AppendStringsToObj (resultObj,
"\"",
command,
" ",
subCommand,
#ifdef UMICH_LDAP
"\" authtype must be one of \"simple\", ",
"\"kerberos_ldap\", \"kerberos_dsa\" ",
"or \"kerberos_both\"",
#else
"\" authtype must be \"simple\", ",
#endif
(char *)NULL);
return TCL_ERROR;
}
binddn = Tcl_GetStringFromObj (objv[3], &stringLength);
if (stringLength == 0)
binddn = NULL;
passwd = Tcl_GetStringFromObj (objv[4], &stringLength);
if (stringLength == 0)
passwd = NULL;
/* ldap_bind_s(ldap, dn, pw, method) */
#ifdef UMICH_LDAP
#define LDAP_BIND(ldap, dn, pw, method) \
ldap_bind_s(ldap, dn, pw, method)
#else
#define LDAP_BIND(ldap, dn, pw, method) \
ldap_simple_bind_s(ldap, dn, pw)
#endif
if ((errcode = LDAP_BIND (ldap,
binddn,
passwd,
ldap_authInt)) != LDAP_SUCCESS) {
Tcl_AppendStringsToObj (resultObj,
"LDAP bind error: ",
ldap_err2string(errcode),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, errcode, interp);
return TCL_ERROR;
}
return TCL_OK;
}
if (STREQU (subCommand, "unbind")) {
if (objc != 2) {
Tcl_WrongNumArgs (interp, 2, objv, "");
return TCL_ERROR;
}
return Tcl_DeleteCommand(interp, Tcl_GetStringFromObj(objv[0], NULL));
}
/* object delete dn */
if (STREQU (subCommand, "delete")) {
if (objc != 3) {
Tcl_WrongNumArgs (interp, 2, objv, "dn");
return TCL_ERROR;
}
dn = Tcl_GetStringFromObj (objv [2], NULL);
if ((errcode = ldap_delete_s(ldap, dn)) != LDAP_SUCCESS) {
Tcl_AppendStringsToObj (resultObj,
"LDAP delete error: ",
ldap_err2string(errcode),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, errcode, interp);
return TCL_ERROR;
}
return TCL_OK;
}
/* object rename_rdn dn rdn */
/* object modify_rdn dn rdn */
if (STREQU (subCommand, "rename_rdn") || STREQU (subCommand, "modify_rdn")) {
char *rdn;
int deleteOldRdn;
if (objc != 4) {
Tcl_WrongNumArgs (interp, 2, objv, "dn rdn");
return TCL_ERROR;
}
dn = Tcl_GetStringFromObj (objv [2], NULL);
rdn = Tcl_GetStringFromObj (objv [3], NULL);
deleteOldRdn = (*subCommand == 'r');
if ((errcode = ldap_modrdn2_s (ldap, dn, rdn, deleteOldRdn)) != LDAP_SUCCESS) {
Tcl_AppendStringsToObj (resultObj,
"LDAP ",
subCommand,
" error: ",
ldap_err2string(errcode),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, errcode, interp);
return TCL_ERROR;
}
return TCL_OK;
}
/* object add dn attributePairList */
/* object add_attributes dn attributePairList */
/* object replace_attributes dn attributePairList */
/* object delete_attributes dn attributePairList */
if (STREQU (subCommand, "add")) {
is_add = 1;
is_add_or_modify = 1;
} else {
is_add = 0;
if (STREQU (subCommand, "add_attributes")) {
is_add_or_modify = 1;
mod_op = LDAP_MOD_ADD;
} else if (STREQU (subCommand, "replace_attributes")) {
is_add_or_modify = 1;
mod_op = LDAP_MOD_REPLACE;
} else if (STREQU (subCommand, "delete_attributes")) {
is_add_or_modify = 1;
mod_op = LDAP_MOD_DELETE;
}
}
if (is_add_or_modify) {
int result;
LDAPMod **modArray;
LDAPMod *mod;
char **valPtrs = NULL;
int attribObjc;
Tcl_Obj **attribObjv;
int valuesObjc;
Tcl_Obj **valuesObjv;
int nPairs, allPairs;
int i;
int j;
int pairIndex;
int modIndex;
Tcl_Obj *resultObj = Tcl_GetObjResult (interp);
if (objc < 4 || objc > 4 && is_add || is_add == 0 && objc&1) {
Tcl_AppendStringsToObj (resultObj,
"wrong # args: ",
Tcl_GetStringFromObj (objv [0], NULL),
" ",
subCommand,
" dn attributePairList",
(char *)NULL);
if (!is_add)
Tcl_AppendStringsToObj (resultObj,
" ?[add|delete|replace] attributePairList ...?", (char *)NULL);
return TCL_ERROR;
}
dn = Tcl_GetStringFromObj (objv [2], NULL);
allPairs = 0;
for (i = 3; i < objc; i += 2) {
if (Tcl_ListObjLength (interp, objv[i], &j) == TCL_ERROR)
return TCL_ERROR;
if (j & 1) {
Tcl_AppendStringsToObj (resultObj,
"attribute list does not contain an ",
"even number of key-value elements",
(char *)NULL);
return TCL_ERROR;
}
allPairs += j / 2;
}
modArray = (LDAPMod **)malloc (sizeof(LDAPMod *) * (allPairs + 1));
pairIndex = 3;
modIndex = 0;
do {
if (Tcl_ListObjGetElements (interp, objv [pairIndex], &attribObjc, &attribObjv)
== TCL_ERROR) {
mod_op = -1;
goto badop;
}
nPairs = attribObjc / 2;
for (i = 0; i < nPairs; i++) {
mod = modArray[modIndex++] = (LDAPMod *) malloc (sizeof(LDAPMod));
mod->mod_op = mod_op;
mod->mod_type = Tcl_GetStringFromObj (attribObjv [i * 2], NULL);
if (Tcl_ListObjGetElements (interp, attribObjv [i * 2 + 1], &valuesObjc, &valuesObjv) == TCL_ERROR) {
/* FIX: cleanup memory here */
mod_op = -1;
goto badop;
}
valPtrs = mod->mod_vals.modv_strvals = \
(char **)malloc (sizeof (char *) * (valuesObjc + 1));
valPtrs[valuesObjc] = (char *)NULL;
for (j = 0; j < valuesObjc; j++) {
valPtrs [j] = Tcl_GetStringFromObj (valuesObjv[j], NULL);
/* If it's "delete" and value is an empty string, make
* value be NULL to indicate entire attribute is to be
* deleted */
if ((*valPtrs [j] == '\0')
&& (mod->mod_op == LDAP_MOD_DELETE || mod->mod_op == LDAP_MOD_REPLACE)) {
valPtrs [j] = NULL;
}
}
}
pairIndex += 2;
if (mod_op != -1 && pairIndex < objc) {
subCommand = Tcl_GetStringFromObj (objv[pairIndex - 1], NULL);
mod_op = -1;
if (STREQU (subCommand, "add")) {
mod_op = LDAP_MOD_ADD;
} else if (STREQU (subCommand, "replace")) {
mod_op = LDAP_MOD_REPLACE;
} else if (STREQU (subCommand, "delete")) {
mod_op = LDAP_MOD_DELETE;
}
if (mod_op == -1) {
Tcl_SetStringObj (resultObj,
"Additional operators must be one of"
" add, replace, or delete", -1);
mod_op = -1;
goto badop;
}
}
} while (mod_op != -1 && pairIndex < objc);
modArray[modIndex] = (LDAPMod *) NULL;
if (is_add) {
result = ldap_add_s (ldap, dn, modArray);
} else {
result = ldap_modify_s (ldap, dn, modArray);
if (ldaptcl->caching)
ldap_uncache_entry (ldap, dn);
}
/* free the modArray elements, then the modArray itself. */
badop:
for (i = 0; i < modIndex; i++) {
free ((char *) modArray[i]->mod_vals.modv_strvals);
free ((char *) modArray[i]);
}
free ((char *) modArray);
/* after modArray is allocated, mod_op = -1 upon error for cleanup */
if (mod_op == -1)
return TCL_ERROR;
/* FIX: memory cleanup required all over the place here */
if (result != LDAP_SUCCESS) {
Tcl_AppendStringsToObj (resultObj,
"LDAP ",
subCommand,
" error: ",
ldap_err2string(result),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, result, interp);
return TCL_ERROR;
}
return TCL_OK;
}
/* object search controlArray dn pattern */
if (STREQU (subCommand, "search")) {
char *controlArrayName;
Tcl_Obj *controlArrayNameObj;
char *scopeString;
int scope;
char *derefString;
int deref;
char *baseString;
char **attributesArray;
char *attributesString;
int attributesArgc;
char *filterPatternString;
char *timeoutString;
double timeoutTime;
struct timeval timeout, *timeout_p;
char *paramString;
int cacheThis = -1;
int all = 0;
char *sortattr;
Tcl_Obj *destArrayNameObj;
Tcl_Obj *evalCodeObj;
if (objc != 5) {
Tcl_WrongNumArgs (interp, 2, objv,
"controlArray destArray code");
return TCL_ERROR;
}
controlArrayNameObj = objv [2];
controlArrayName = Tcl_GetStringFromObj (controlArrayNameObj, NULL);
destArrayNameObj = objv [3];
evalCodeObj = objv [4];
baseString = Tcl_GetVar2 (interp,
controlArrayName,
"base",
0);
if (baseString == (char *)NULL) {
Tcl_AppendStringsToObj (resultObj,
"required element \"base\" ",
"is missing from ldap control array \"",
controlArrayName,
"\"",
(char *)NULL);
return TCL_ERROR;
}
filterPatternString = Tcl_GetVar2 (interp,
controlArrayName,
"filter",
0);
if (filterPatternString == (char *)NULL) {
filterPatternString = "(objectclass=*)";
}
/* Fetch scope setting from control array.
* If it doesn't exist, default to subtree scoping.
*/
scopeString = Tcl_GetVar2 (interp, controlArrayName, "scope", 0);
if (scopeString == NULL) {
scope = LDAP_SCOPE_SUBTREE;
} else {
if (STREQU(scopeString, "base"))
scope = LDAP_SCOPE_BASE;
else if (STRNEQU(scopeString, "one", 3))
scope = LDAP_SCOPE_ONELEVEL;
else if (STRNEQU(scopeString, "sub", 3))
scope = LDAP_SCOPE_SUBTREE;
else {
Tcl_AppendStringsToObj (resultObj,
"\"scope\" element of \"",
controlArrayName,
"\" array is not one of ",
"\"base\", \"onelevel\", ",
"or \"subtree\"",
(char *) NULL);
return TCL_ERROR;
}
}
#ifdef LDAP_OPT_DEREF
/* Fetch dereference control setting from control array.
* If it doesn't exist, default to never dereference. */
derefString = Tcl_GetVar2 (interp,
controlArrayName,
"deref",
0);
if (derefString == (char *)NULL) {
deref = LDAP_DEREF_NEVER;
} else {
if (STREQU(derefString, "never"))
deref = LDAP_DEREF_NEVER;
else if (STREQU(derefString, "search"))
deref = LDAP_DEREF_SEARCHING;
else if (STREQU(derefString, "find"))
deref = LDAP_DEREF_FINDING;
else if (STREQU(derefString, "always"))
deref = LDAP_DEREF_ALWAYS;
else {
Tcl_AppendStringsToObj (resultObj,
"\"deref\" element of \"",
controlArrayName,
"\" array is not one of ",
"\"never\", \"search\", \"find\", ",
"or \"always\"",
(char *) NULL);
return TCL_ERROR;
}
}
#endif
/* Fetch list of attribute names from control array.
* If entry doesn't exist, default to NULL (all).
*/
attributesString = Tcl_GetVar2 (interp,
controlArrayName,
"attributes",
0);
if (attributesString == (char *)NULL) {
attributesArray = NULL;
} else {
if ((Tcl_SplitList (interp,
attributesString,
&attributesArgc,
&attributesArray)) != TCL_OK) {
return TCL_ERROR;
}
}
/* Fetch timeout value if there is one
*/
timeoutString = Tcl_GetVar2 (interp,
controlArrayName,
"timeout",
0);
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;
}
paramString = Tcl_GetVar2 (interp, controlArrayName, "cache", 0);
if (paramString) {
if (Tcl_GetInt(interp, paramString, &cacheThis) == TCL_ERROR)
return TCL_ERROR;
}
paramString = Tcl_GetVar2 (interp, controlArrayName, "all", 0);
if (paramString) {
if (Tcl_GetInt(interp, paramString, &all) == TCL_ERROR)
return TCL_ERROR;
}
sortattr = Tcl_GetVar2 (interp, controlArrayName, "sort", 0);
#ifdef UMICH_LDAP
ldap->ld_deref = deref;
ldap->ld_timelimit = 0;
ldap->ld_sizelimit = 0;
ldap->ld_options = 0;
#endif
/* Caching control within the search: if the "cache" control array */
/* value is set, disable/enable caching accordingly */
#if 0
if (cacheThis >= 0 && ldaptcl->caching != cacheThis) {
if (cacheThis) {
if (ldaptcl->timeout == 0) {
Tcl_SetStringObj(resultObj, "Caching never before enabled, I have no timeout value to use", -1);
return TCL_ERROR;
}
ldap_enable_cache(ldap, ldaptcl->timeout, ldaptcl->maxmem);
}
else
ldap_disable_cache(ldap);
}
#endif
#ifdef LDAP_OPT_DEREF
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
#endif
tclResult = LDAP_PerformSearch (interp,
ldaptcl,
baseString,
scope,
attributesArray,
filterPatternString,
"",
destArrayNameObj,
evalCodeObj,
timeout_p,
all,
sortattr);
/* Following the search, if we changed the caching behavior, change */
/* it back. */
#if 0
if (cacheThis >= 0 && ldaptcl->caching != cacheThis) {
if (cacheThis)
ldap_disable_cache(ldap);
else
ldap_enable_cache(ldap, ldaptcl->timeout, ldaptcl->maxmem);
}
#ifdef LDAP_OPT_DEREF
deref = LDAP_DEREF_NEVER;
ldap_set_option(ldap, LDAP_OPT_DEREF, &deref);
#endif
#endif
return tclResult;
}
/* object compare dn attr value */
if (STREQU (subCommand, "compare")) {
char *dn;
char *attr;
char *value;
int result;
int lderrno;
if (objc != 5) {
Tcl_WrongNumArgs (interp,
2, objv,
"dn attribute value");
return TCL_ERROR;
}
dn = Tcl_GetStringFromObj (objv[2], NULL);
attr = Tcl_GetStringFromObj (objv[3], NULL);
value = Tcl_GetStringFromObj (objv[4], NULL);
result = ldap_compare_s (ldap, dn, attr, value);
if (result == LDAP_COMPARE_TRUE || result == LDAP_COMPARE_FALSE) {
Tcl_SetBooleanObj(resultObj, result == LDAP_COMPARE_TRUE);
return TCL_OK;
}
LDAP_SetErrorCode(ldaptcl, result, interp);
Tcl_AppendStringsToObj (resultObj,
"LDAP compare error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
return TCL_ERROR;
}
if (STREQU (subCommand, "cache")) {
#if defined(UMICH_LDAP) || (defined(OPEN_LDAP) && !defined(LDAP_API_VERSION))
char *cacheCommand;
if (objc < 3) {
badargs:
Tcl_WrongNumArgs (interp, 2, objv [0], "command [args...]");
return TCL_ERROR;
}
cacheCommand = Tcl_GetStringFromObj (objv [2], NULL);
if (STREQU (cacheCommand, "uncache")) {
char *dn;
if (objc != 4) {
Tcl_WrongNumArgs (interp,
3, objv,
"dn");
return TCL_ERROR;
}
dn = Tcl_GetStringFromObj (objv [3], NULL);
ldap_uncache_entry (ldap, dn);
return TCL_OK;
}
if (STREQU (cacheCommand, "enable")) {
long timeout = ldaptcl->timeout;
long maxmem = ldaptcl->maxmem;
if (objc > 5) {
Tcl_WrongNumArgs (interp, 3, objv, "?timeout? ?maxmem?");
return TCL_ERROR;
}
if (objc > 3) {
if (Tcl_GetLongFromObj (interp, objv [3], &timeout) == TCL_ERROR)
return TCL_ERROR;
}
if (timeout == 0) {
Tcl_SetStringObj(resultObj,
objc > 3 ? "timeouts must be greater than 0" :
"no previous timeout to reference", -1);
return TCL_ERROR;
}
if (objc > 4)
if (Tcl_GetLongFromObj (interp, objv [4], &maxmem) == TCL_ERROR)
return TCL_ERROR;
if (ldap_enable_cache (ldap, timeout, maxmem) == -1) {
Tcl_AppendStringsToObj (resultObj,
"LDAP cache enable error: ",
LDAP_ERR_STRING(ldap),
(char *)NULL);
LDAP_SetErrorCode(ldaptcl, -1, interp);
return TCL_ERROR;
}
ldaptcl->caching = 1;
ldaptcl->timeout = timeout;
ldaptcl->maxmem = maxmem;
return TCL_OK;
}
if (objc != 3) goto badargs;
if (STREQU (cacheCommand, "disable")) {
ldap_disable_cache (ldap);
ldaptcl->caching = 0;
return TCL_OK;
}
if (STREQU (cacheCommand, "destroy")) {
ldap_destroy_cache (ldap);
ldaptcl->caching = 0;
return TCL_OK;
}
if (STREQU (cacheCommand, "flush")) {
ldap_flush_cache (ldap);
return TCL_OK;
}
if (STREQU (cacheCommand, "no_errors")) {
ldap_set_cache_options (ldap, LDAP_CACHE_OPT_CACHENOERRS);
return TCL_OK;
}
if (STREQU (cacheCommand, "all_errors")) {
ldap_set_cache_options (ldap, LDAP_CACHE_OPT_CACHEALLERRS);
return TCL_OK;
}
if (STREQU (cacheCommand, "size_errors")) {
ldap_set_cache_options (ldap, 0);
return TCL_OK;
}
Tcl_AppendStringsToObj (resultObj,
"\"",
command,
" ",
subCommand,
"\" subcommand",
" must be one of \"enable\", ",
"\"disable\", ",
"\"destroy\", \"flush\", \"uncache\", ",
"\"no_errors\", \"size_errors\",",
" or \"all_errors\"",
(char *)NULL);
return TCL_ERROR;
#else
return TCL_OK;
#endif
}
if (STREQU (subCommand, "trap")) {
Tcl_Obj *listObj, *resultObj;
int *p, l, i, code;
if (objc > 4) {
Tcl_WrongNumArgs (interp, 2, objv,
"command ?errorCode-list?");
return TCL_ERROR;
}
if (objc == 2) {
if (!ldaptcl->trapCmdObj)
return TCL_OK;
resultObj = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(interp, resultObj, ldaptcl->trapCmdObj);
if (ldaptcl->traplist) {
listObj = Tcl_NewObj();
for (p = ldaptcl->traplist; *p; p++) {
Tcl_ListObjAppendElement(interp, listObj,
Tcl_NewStringObj(ldaptclerrorcode[*p], -1));
}
Tcl_ListObjAppendElement(interp, resultObj, listObj);
}
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
if (ldaptcl->trapCmdObj) {
Tcl_DecrRefCount (ldaptcl->trapCmdObj);
ldaptcl->trapCmdObj = NULL;
}
if (ldaptcl->traplist) {
free(ldaptcl->traplist);
ldaptcl->traplist = NULL;
}
Tcl_GetStringFromObj(objv[2], &l);
if (l == 0)
return TCL_OK; /* just turn off trap */
ldaptcl->trapCmdObj = objv[2];
Tcl_IncrRefCount (ldaptcl->trapCmdObj);
if (objc < 4)
return TCL_OK; /* no code list */
if (Tcl_ListObjLength(interp, objv[3], &l) != TCL_OK)
return TCL_ERROR;
if (l == 0)
return TCL_OK; /* empty code list */
ldaptcl->traplist = (int*)malloc(sizeof(int) * (l + 1));
ldaptcl->traplist[l] = 0;
for (i = 0; i < l; i++) {
Tcl_ListObjIndex(interp, objv[3], i, &resultObj);
code = LDAP_ErrorStringToCode(interp, Tcl_GetStringFromObj(resultObj, NULL));
if (code == -1) {
free(ldaptcl->traplist);
ldaptcl->traplist = NULL;
return TCL_ERROR;
}
ldaptcl->traplist[i] = code;
}
return TCL_OK;
}
if (STREQU (subCommand, "trapcodes")) {
int code;
Tcl_Obj *resultObj;
Tcl_Obj *stringObj;
resultObj = Tcl_GetObjResult(interp);
for (code = 0; code < LDAPTCL_MAXERR; code++) {
if (!ldaptclerrorcode[code]) continue;
Tcl_ListObjAppendElement(interp, resultObj,
Tcl_NewStringObj(ldaptclerrorcode[code], -1));
}
return TCL_OK;
}
#ifdef LDAP_DEBUG
if (STREQU (subCommand, "debug")) {
if (objc != 3) {
Tcl_AppendStringsToObj(resultObj, "Wrong # of arguments",
(char*)NULL);
return TCL_ERROR;
}
return Tcl_GetIntFromObj(interp, objv[2], &ldap_debug);
}
#endif
/* FIX: this needs to enumerate all the possibilities */
Tcl_AppendStringsToObj (resultObj,
"subcommand \"",
subCommand,
"\" must be one of \"add\", ",
"\"add_attributes\", ",
"\"bind\", \"cache\", \"delete\", ",
"\"delete_attributes\", \"modify\", ",
"\"modify_rdn\", \"rename_rdn\", ",
"\"replace_attributes\", ",
"\"search\" or \"unbind\".",
(char *)NULL);
return TCL_ERROR;
}
/*
* Delete and LDAP command object
*
*/
static void
NeoX_LdapObjDeleteCmd(clientData)
ClientData clientData;
{
LDAPTCL *ldaptcl = (LDAPTCL *)clientData;
LDAP *ldap = ldaptcl->ldap;
if (ldaptcl->trapCmdObj)
Tcl_DecrRefCount (ldaptcl->trapCmdObj);
if (ldaptcl->traplist)
free(ldaptcl->traplist);
ldap_unbind(ldap);
free((char*) ldaptcl);
}
/*-----------------------------------------------------------------------------
* NeoX_LdapObjCmd --
*
* Implements the `ldap' command:
* ldap open newObjName host [port]
* ldap init newObjName host [port]
*
* Results:
* A standard Tcl result.
*
* Side effects:
* See the user documentation.
*-----------------------------------------------------------------------------
*/
static int
NeoX_LdapObjCmd (clientData, interp, objc, objv)
ClientData clientData;
Tcl_Interp *interp;
int objc;
Tcl_Obj *CONST objv[];
{
extern int errno;
char *subCommand;
char *newCommand;
char *ldapHost;
int ldapPort = LDAP_PORT;
LDAP *ldap;
LDAPTCL *ldaptcl;
Tcl_Obj *resultObj = Tcl_GetObjResult (interp);
if (objc < 3) {
Tcl_WrongNumArgs (interp, 1, objv,
"(open|init) new_command host [port]|explode dn");
return TCL_ERROR;
}
subCommand = Tcl_GetStringFromObj (objv[1], NULL);
if (STREQU(subCommand, "explode")) {
char *param;
int nonames = 0;
int list = 0;
char **exploded, **p;
param = Tcl_GetStringFromObj (objv[2], NULL);
if (param[0] == '-') {
if (STREQU(param, "-nonames")) {
nonames = 1;
} else if (STREQU(param, "-list")) {
list = 1;
} else {
Tcl_WrongNumArgs (interp, 1, objv, "explode ?-nonames|-list? dn");
return TCL_ERROR;
}
}
if (nonames || list)
param = Tcl_GetStringFromObj (objv[3], NULL);
exploded = ldap_explode_dn(param, nonames);
for (p = exploded; *p; p++) {
if (list) {
char *q = strchr(*p, '=');
if (!q) {
Tcl_SetObjLength(resultObj, 0);
Tcl_AppendStringsToObj(resultObj, "rdn ", *p,
" missing '='", NULL);
ldap_value_free(exploded);
return TCL_ERROR;
}
*q = '\0';
if (Tcl_ListObjAppendElement(interp, resultObj,
Tcl_NewStringObj(*p, -1)) != TCL_OK ||
Tcl_ListObjAppendElement(interp, resultObj,
Tcl_NewStringObj(q+1, -1)) != TCL_OK) {
ldap_value_free(exploded);
return TCL_ERROR;
}
} else {
if (Tcl_ListObjAppendElement(interp, resultObj,
Tcl_NewStringObj(*p, -1))) {
ldap_value_free(exploded);
return TCL_ERROR;
}
}
}
ldap_value_free(exploded);
return TCL_OK;
}
#ifdef UMICH_LDAP
if (STREQU(subCommand, "friendly")) {
char *friendly = ldap_dn2ufn(Tcl_GetStringFromObj(objv[2], NULL));
Tcl_SetStringObj(resultObj, friendly, -1);
free(friendly);
return TCL_OK;
}
#endif
newCommand = Tcl_GetStringFromObj (objv[2], NULL);
ldapHost = Tcl_GetStringFromObj (objv[3], NULL);
if (objc == 5) {
if (Tcl_GetIntFromObj (interp, objv [4], &ldapPort) == TCL_ERROR) {
Tcl_AppendStringsToObj (resultObj,
"LDAP port number is non-numeric",
(char *)NULL);
return TCL_ERROR;
}
}
if (STREQU (subCommand, "open")) {
ldap = ldap_open (ldapHost, ldapPort);
} else if (STREQU (subCommand, "init")) {
int version = -1;
int i;
int value;
char *subOption;
char *subValue;
#if LDAPTCL_PROTOCOL_VERSION_DEFAULT
version = LDAPTCL_PROTOCOL_VERSION_DEFAULT;
#endif
for (i = 6; i < objc; i += 2) {
subOption = Tcl_GetStringFromObj(objv[i-1], NULL);
if (STREQU (subOption, "protocol_version")) {
#ifdef LDAP_OPT_PROTOCOL_VERSION
subValue = Tcl_GetStringFromObj(objv[i], NULL);
if (STREQU (subValue, "2")) {
version = LDAP_VERSION2;
}
else if (STREQU (subValue, "3")) {
#ifdef LDAP_VERSION3
version = LDAP_VERSION3;
#else
Tcl_SetStringObj (resultObj, "protocol_version 3 not supported", -1);
return TCL_ERROR;
#endif
}
else {
Tcl_SetStringObj (resultObj, "protocol_version must be '2' or '3'", -1);
return TCL_ERROR;
}
#else
Tcl_SetStringObj (resultObj, "protocol_version not supported", -1);
return TCL_ERROR;
#endif
} else if (STREQU (subOption, "port")) {
if (Tcl_GetIntFromObj (interp, objv [i], &ldapPort) == TCL_ERROR) {
Tcl_AppendStringsToObj (resultObj,
"LDAP port number is non-numeric",
(char *)NULL);
return TCL_ERROR;
}
} else {
Tcl_SetStringObj (resultObj, "valid options: protocol_version, port", -1);
return TCL_ERROR;
}
}
ldap = ldap_init (ldapHost, ldapPort);
#if LDAP_OPT_PROTOCOL_VERSION
if (version != -1)
ldap_set_option(ldap, LDAP_OPT_PROTOCOL_VERSION, &version);
#endif
} else {
Tcl_AppendStringsToObj (resultObj,
"option was not \"open\" or \"init\"");
return TCL_ERROR;
}
if (ldap == (LDAP *)NULL) {
Tcl_SetErrno(errno);
Tcl_AppendStringsToObj (resultObj,
Tcl_PosixError (interp),
(char *)NULL);
return TCL_ERROR;
}
#if UMICH_LDAP
ldap->ld_deref = LDAP_DEREF_NEVER; /* Turn off alias dereferencing */
#endif
ldaptcl = (LDAPTCL *) malloc(sizeof(LDAPTCL));
ldaptcl->ldap = ldap;
ldaptcl->caching = 0;
ldaptcl->timeout = 0;
ldaptcl->maxmem = 0;
ldaptcl->trapCmdObj = NULL;
ldaptcl->traplist = NULL;
ldaptcl->flags = 0;
Tcl_CreateObjCommand (interp,
newCommand,
NeoX_LdapTargetObjCmd,
(ClientData) ldaptcl,
NeoX_LdapObjDeleteCmd);
return TCL_OK;
}
/*-----------------------------------------------------------------------------
* Neo_initLDAP --
* Initialize the LDAP interface.
*-----------------------------------------------------------------------------
*/
int
Ldaptcl_Init (interp)
Tcl_Interp *interp;
{
Tcl_CreateObjCommand (interp,
"ldap",
NeoX_LdapObjCmd,
(ClientData) NULL,
(Tcl_CmdDeleteProc*) NULL);
/*
if (Neo_initLDAPX(interp) != TCL_OK)
return TCL_ERROR;
*/
Tcl_PkgProvide(interp, "Ldaptcl", VERSION);
return TCL_OK;
}
package ifneeded Ldaptcl @NEO_VERSION@ "package require Tclx 8.0; load [file join $dir .. @NEO_SHARED_LIB_FILE@] Ldaptcl"