Compare commits

..

12 Commits

Author SHA1 Message Date
mhein%netscape.com
1094bbecd8 Add rules for building ldap->nspr interface
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80732 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-09 16:35:58 +00:00
mhein%netscape.com
e7cc9a1ca1 Add libprldap
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80731 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-09 16:35:13 +00:00
mhein%netscape.com
155e2b78e8 Build NSPR as part of C SDK build....need generated header file
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80730 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-09 16:34:17 +00:00
mhein%netscape.com
26bd1be8a6 Remove Makefile
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80595 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-06 21:25:42 +00:00
mhein%netscape.com
4aad72eee3 Change version to 4.1
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80594 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-06 21:01:54 +00:00
mhein%netscape.com
3221592283 Change version to 4.1
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80593 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-06 20:55:12 +00:00
mhein%netscape.com
88c5957a61 Fix mangled .c files
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80592 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-06 20:04:29 +00:00
mhein%netscape.com
c43a7a4586 Fix mangled header files
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80591 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-06 19:52:36 +00:00
mhein%netscape.com
c10bcef97d Fix mangled header files
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80590 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-06 19:45:12 +00:00
mhein%netscape.com
e79d293e43 Fix mangled portable.h
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80589 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-06 19:41:54 +00:00
mhein%netscape.com
a67f9feefa Initial sync of Internal 4.1 C SDK
git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@80584 18797224-902f-48f8-a5cc-f745e15eee43
2000-10-06 17:46:21 +00:00
(no author)
bb8031e82c This commit was manufactured by cvs2svn to create branch
'LDAPCSDK_41_BRANCH'.

git-svn-id: svn://10.0.0.236/branches/LDAPCSDK_41_BRANCH@74850 18797224-902f-48f8-a5cc-f745e15eee43
2000-07-26 23:08:09 +00:00
1012 changed files with 217938 additions and 106012 deletions

View File

@@ -0,0 +1,88 @@
#! gmake
#
# The contents of this file are subject to the Netscape Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/NPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s):
#
#
#
# You need to have checked out the LDAP tree at the same level as ns
# in order to build LDAP.
#
LDAP_DEPTH = .
NSPR_TREE = ../nsprpub
MOD_DEPTH = ../nsprpub
NSPR_VERSION = 3.5.1
DEPTH = ..
include $(NSPR_TREE)/config/rules.mk
all export:: FORCE
@if [ -d $(NSPR_TREE)/ ]; then \
cd $(NSPR_TREE); \
$(MAKE); \
else \
echo "No NSPR $(NSPR_VERSION) directory found"; \
exit 0; \
fi
@if [ -d $(LDAP_DEPTH)/c-sdk/ldap ]; then \
cd $(LDAP_DEPTH)/c-sdk/ldap; \
$(MAKE) -f Makefile.client $(MFLAGS) export; \
else \
echo "No LDAP directory -- skipping"; \
exit 0; \
fi
libs install:: FORCE
@if [ -d $(LDAP_DEPTH)/c-sdk/ldap ]; then \
cd $(LDAP_DEPTH)/c-sdk/ldap; \
$(MAKE) -f Makefile.client $(MFLAGS) install; \
else \
echo "No LDAP directory -- skipping"; \
exit 0; \
fi
clean clobber:: FORCE
@if [ -d $(NSPR_TREE)/ ]; then \
cd $(NSPR_TREE); \
$(MAKE) clean; \
else \
echo "No NSPR $(NSPR_VERSION) directory found"; \
exit 0; \
fi
@if [ -d $(LDAP_DEPTH)/c-sdk/ldap ]; then \
cd $(LDAP_DEPTH)/c-sdk/ldap; \
$(MAKE) -f Makefile.client $(MFLAGS) clean; \
else \
echo "No LDAP directory -- skipping"; \
exit 0; \
fi
rm -rf ../dist
realclean clobber_all:: FORCE
@if [ -d $(LDAP_DEPTH)/c-sdk/ldap ]; then \
cd $(LDAP_DEPTH)/c-sdk/ldap; \
$(MAKE) -f Makefile.client $(MFLAGS) realclean; \
else \
echo "No LDAP directory -- skipping"; \
exit 0; \
fi
FORCE:

View File

@@ -0,0 +1,154 @@
======================================================================
NETSCAPE DIRECTORY SDK FOR C:
BUILD INSTRUCTIONS
Last updated: May 31, 1998
======================================================================
For information on the Netscape Directory SDK source release,
see http://www.mozilla.org/directory/
Unix/Linux Build Instructions
-----------------------------
System Requirements:
32MB of RAM, 128MB of swap, recommended 64MB of RAM.
Tool Requirements:
Native C compiler or GNU C/C++ compiler 2.7.2
(or a more recent version)
GNU make 3.74 or a more recent version
Instructions:
1. Uncompress and extract the source files by entering the
following command (or your preferred variant of this command):
gzip -dc <filename>.tar.gz | tar -xvf -
2. Set and unset the following environment variables.
In csh/tcsh:
setenv MOZILLA_CLIENT 1
setenv NO_MDUPDATE 1
setenv MOZ_LDAP_SDK 1
unsetenv MOZ_LI
unsetenv MOZ_LITE
unsetenv MOZ_MEDIUM
unsetenv NO_SECURITY
In sh/bash/ksh:
MOZILLA_CLIENT=1
NO_MDUPDATE=1
MOZ_LDAP_SDK=1
export MOZILLA_CLIENT NO_MDUPDATE MOZ_LDAP_SDK
unset MOZ_LI
unset MOZ_LITE
unset MOZ_MEDIUM
unset NO_SECURITY
3. Build the SDK by entering the following commands:
cd mozilla
gmake -f directory/ldapsdk.mk build
The SDK will be built and copied into the following directories:
mozilla/dist/public/ldap - header files
mozilla/dist/<architecture>/bin - LDAP API shared object/libraries
(libldap.so, liblber.so)
Windows Build Instructions
--------------------------
System Requirements:
Windows NT 3.51 or 4.0 (4.0 preferred).
Tool Requirements:
Microsoft Visual C++ version 4.2 or a more recent version
GNU Tools for Windows (you can find these on the Internet).
Specifically, you'll need:
cp.exe
rm.exe
Here are some sample download sites to find these:
Cygnus (http://www.cygnus.com/misc/gnu-win32)
GNU (http://www.gnu.org/order/ftp.html)
MIT (ftp://prep.ai.mit.edu/pub/gnu)
Netscape uses internally modified versions of the following tools:
gmake.exe
shmsdos.exe
uname.exe
You can download them from http://www.mozilla.org/download-mozilla.html
(click the Windows Build Tools link). When you unzip the file, the
tools will be located in the windows\bin\x86 directory.
Netscape-developed tools (makedep.exe, txt2rc.exe, waitfor.exe),
which are located in the mozilla\cmd\winfe\mkfiles32 directory
All of these tools need to be put in your path.
Extracting the Source Files:
The source files for the Directory C SDK are zipped in the file
ldap-c-sdk.zip. When unzipping the file, make sure to specify
that you want to preserve the directory structure. For example,
make sure that "Use Folder Names" is checked.
Instructions:
NOTE: Make sure to run the commands from a standard Windows NT
command prompt. Although you may be able to use other shells
to build the SDK, you may need to adjust the makefiles for
the shell that you are using.
1. Set the following environment variables (within the command session,
either manually or via a script), or within the system environment
through the Control Panel | System control panel):
set HOME=(your home directory)
set MOZ_BITS=32
set MOZ_DEBUG=1
set MOZ_GOLD=0
set MOZ_JAVA=0
set MOZ_NT=351 (if running NT 3.51, don't set otherwise)
set MOZ_SRC=(top of your source tree, drive letter and path.
For example, set MOZ_SRC=d:\mozilla_src, if the mozilla
directory is at d:\mozilla_src\mozilla.)
set MOZ_TOOLS=(location of the bin directory containing your
GNU tools. The build looks for MOZ_TOOLS\bin\gmake.exe,
so make sure that the MOZ_TOOLS environment variable
is set correctly.)
set PATH=%MOZ_TOOLS%\bin;%PATH%
set TEMP=(your temp directory)
set TMP=(your temp directory)
set VERBOSE=1
Unset the following environment variables:
set MOZ_LI=
set MOZ_LITE=
set MOZ_MEDIUM=
2. Enter the following commands to build the SDK:
cd mozilla\directory
nmake -f ldapsdk.mak
The SDK will be built and copied into the following directories:
mozilla\dist\public\ldap - header files
mozilla\dist\Win32_d.obj\bin - LDAP API DLL (nsldap32.dll)
mozilla\dist\Win32_d.obj\lib - import and static libraries
(nsldap32.lib, nsldap32s.lib)
Notes:
This build process does not use Visual C++ generated project files.
(Reasons for this include size, maintainability, and the long-term
desire to use tools like gmake or plug-and-play developer tools.)
This does not preclude you from using the Visual C++ IDE or its debugger.
Common Build Problems:
If the build fails with the message "'.\WIN32' unexpected",
you didn't set the environment variables correctly. Check for
extra spaces at the end of the set statements (this is a
common problem when copying and pasting commands).
If directory-related errors are reported, check the full path to
the source for any spaces. Make sure that when you originally extracted
the source files, you used a utility that understands long filenames.
If you are not sure if your extraction utility understands long filenames,
use Info-Zip. (You can get this from ftp://ftp.cdrom.com/pub/infozip.)
--------------------------------------------------------
Copyright (c) 1998 Netscape Communications Corporation.
(http://home.netscape.com/misc/contact_info.html)

View File

@@ -0,0 +1,34 @@
DEPTH = ../../..
NSPR_TREE = ../../../nsprpub
MOD_DEPTH = ../../../nsprpub
SRCDIRS = build include libraries
include $(NSPR_TREE)/config/rules.mk
all export:: FORCE
@for i in $(SRCDIRS); do \
echo " cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) export"; \
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) export ); \
done
libs install:: FORCE
@for i in $(SRCDIRS); do \
echo "cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) install"; \
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) install ); \
done
clean clobber:: FORCE
@for i in $(SRCDIRS); do \
echo "cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) clean"; \
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) clean ); \
done
realclean clobber_all:: FORCE
@for i in $(SRCDIRS); do \
echo "cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) realclean"; \
( cd $$i; $(MAKE) -f Makefile.client $(MFLAGS) realclean ); \
done
FORCE:

View File

@@ -0,0 +1,35 @@
DEPTH = ../../..
srcdir = @srcdir@
ldaptopsrcdir = @top_srcdir@
SRCDIRS = build include libraries
include build/autoconf.mk
include $(NSPR_TREE)/config/rules.mk
all export:: FORCE
@for i in $(SRCDIRS); do \
echo " cd $$i; $(MAKE) $(MFLAGS) export"; \
( cd $$i; $(MAKE) $(MFLAGS) export ); \
done
libs install:: FORCE
@for i in $(SRCDIRS); do \
echo "cd $$i; $(MAKE) $(MFLAGS) install"; \
( cd $$i; $(MAKE) $(MFLAGS) install ); \
done
clean clobber:: FORCE
@for i in $(SRCDIRS); do \
echo "cd $$i; $(MAKE) $(MFLAGS) clean"; \
( cd $$i; $(MAKE) $(MFLAGS) clean ); \
done
realclean clobber_all:: FORCE
@for i in $(SRCDIRS); do \
echo "cd $$i; $(MAKE) $(MFLAGS) realclean"; \
( cd $$i; $(MAKE) $(MFLAGS) realclean ); \
done
FORCE:

View File

@@ -0,0 +1,31 @@
The autoconf files here are the barest shim to allow the LDAP C SDK to
build with autoconf, including in a --objdir. These are really just a
wrapper around the existing (NSPR-based) build-system; they propagate
very little information from the autconf command line or environment.
The Makefile.in files are all just slightly edited forks of the
Makefile.client files. These files are:
Makefile.in
configure
configure.in
build/Makefile.in
build/autoconf.mk.in
build/my_overrides.mk
include/Makefile.in
libraries/Makefile.in
libraries/liblber/Makefile.in
libraries/libldap/Makefile.in
Note that as in the main browser tree, I've checked in the (generated)
configure script so that autoconf isn't a prerequisite to build.
At some point after the most current LDAP SDK code lands in Mozilla,
then perhaps it will be worth spending some time creating a more
correctly autoconfified build process that isn't just a shim and
doesn't depend on NSPR.
Comments to <news://news.mozilla.org/netscape.public.mozilla.directory>,
please.
Dan Mosedale
<dmose@mozilla.org>

View File

@@ -0,0 +1,28 @@
DEPTH = ../../../..
MOD_DEPTH = ../../../../nsprpub
NSPR_TREE = ../../../../nsprpub
CSRCS = dirver.c
include $(NSPR_TREE)/config/rules.mk
TARGETS = $(OBJDIR)/dirver$(BIN_SUFFIX)
GARBAGE += $(TARGETS)
ifeq ($(OS_ARCH), OS2)
$(OBJS) = $(addprefix $(OBJDIR)/, $(CSRCS:.c=.o))
$(TARGETS): $(OBJS)
@$(MAKE_OBJDIR)
$(LINK_EXE) -OUT:$@ $(OBJS)
endif
export:: $(TARGETS)
$(INSTALL) -m 555 $(TARGETS) $(DIST)/bin
install:: export
clean::
rm -rf $(OBJDIR_NAME)

View File

@@ -0,0 +1,29 @@
DEPTH = ../../../..
srcdir = @srcdir@
ldaptopsrcdir = @top_srcdir@
CSRCS = dirver.c
include autoconf.mk
include $(NSPR_TREE)/config/rules.mk
TARGETS = $(OBJDIR)/dirver$(BIN_SUFFIX)
GARBAGE += $(TARGETS)
ifeq ($(OS_ARCH), OS2)
$(OBJS) = $(addprefix $(OBJDIR)/, $(CSRCS:.c=.o))
$(TARGETS): $(OBJS)
@$(MAKE_OBJDIR)
$(LINK_EXE) -OUT:$@ $(OBJS)
endif
export:: $(TARGETS)
$(INSTALL) -m 555 $(TARGETS) $(DIST)/bin
install:: export
clean::
rm -rf $(OBJDIR_NAME)

View File

@@ -0,0 +1,57 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org LDAP SDK autoconf glue.
#
# The Initial Developer of the Original Code is Netscape
# Commmunications Corp. Portions created by Netscape are
# Copyright (C) 2000, Netscape Communications Corp. All
# Rights Reserved.
#
# Contributor(s): Dan Mosedale <dmose@mozilla.org>
#
# this is used to override DIST and VPATH
#
NSPR_MY_OVERRIDES_MK = $(ldaptopsrcdir)/build/my_overrides.mk
# common to all the ldap sdk makefiles
#
NSPR_TREE = $(ldaptopsrcdir)/../../../nsprpub
topsrcdir = $(ldaptopsrcdir)/../../../nsprpub
# various stuff from the ldap sdk documentation
#
MOZILLA_CLIENT = 1
NO_MDUPDATE = 1
MOZ_LDAP_SDK = 1
MOZ_LI =
MOZ_LITE =
MOZ_MEDIUM =
NO_SECURITY =
# we have to cope if nspr was built using autoconf (which we only know is
# is true if our configure was passed --enable-nspr-autoconf -- which
# the top-level configure does automagically, as appropriate).
#
NSPR_USE_AUTOCONF = @NSPR_USE_AUTOCONF@
ifeq ($(NSPR_USE_AUTOCONF), 1)
MOD_DEPTH = $(DEPTH)
include $(DEPTH)/nsprpub/config/autoconf.mk
VPATH = $(srcdir)
DIST = $(DEPTH)/dist
else
MOD_DEPTH = $(NSPR_TREE)
endif

View File

@@ -0,0 +1,217 @@
/*--------------------------------------------------------------------------
/ Copyright (C) 1996, 1997 Netscape Communications Corporation
/ --------------------------------------------------------------------------
/
/ Name: Netscape File Version Generator
/ Platforms: WIN32
/ ......................................................................
/ This program generates an ascii format of the 64-bit FILEVERSION
/ resource identifier used by Windows executable binaries.
/
/ Usage Syntax:
/ fversion <major.minor.patch> [mm/dd/yyyy] [outfile]
/ If date is not specified, the current GMT date is used. yyyy must be
/ greater than 1980
/
/ Usage Example:
/ fversion 3.0.0
/ fversion 6.5.4 1/30/2001
/ fversion 6.5.4 1/30/2001 fileversion.h
/
/ see http://ntsbuild/sd/30ver.htm for specification
/ ......................................................................
/ Revision History:
/ 01-30-97 Initial Version, Andy Hakim (ahakim@netscape.com)
/ --------------------------------------------------------------------------*/
#ifdef _WIN32
#include <windows.h>
#endif
#ifdef macintosh
#include <console.h>
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
unsigned _CalcVersion(unsigned nMajor, unsigned nMinor, unsigned nPatch)
{
unsigned nVersion;
nVersion = nMajor;
nVersion <<= 5;
nVersion += nMinor;
nVersion <<= 7;
nVersion += nPatch;
nVersion &= 0xFFFF;
return(nVersion);
}
static void _GetVersions(char *szVer, unsigned *nMajor, unsigned *nMinor,
unsigned *nPatch)
{
char szVersion[128];
unsigned nReturn = 0;
char *szToken;
*nMajor = 0;
*nMinor = 0;
*nPatch = 0;
strcpy(szVersion, szVer);
if(szToken = strtok(szVersion, ".\n"))
{
*nMajor = atoi(szToken);
if(szToken = strtok(NULL, ".\n"))
{
*nMinor = atoi(szToken);
if(szToken = strtok(NULL, ".\n"))
{
*nPatch = atoi(szToken);
}
}
}
}
unsigned _CalcBuildDate(unsigned nYear, unsigned nMonth, unsigned nDay)
{
unsigned nBuildDate = 0;
if(nYear < 1900) /* they really mean 1900 + nYear */
nYear += 1900;
nYear -= 1980;
nBuildDate = nYear;
/*
nBuildDate <<= 5;
*/
nBuildDate <<= 4;
nBuildDate += nMonth;
/* nBuildDate <<= 4; */
nBuildDate <<= 5;
nBuildDate += nDay;
nBuildDate &= 0xFFFF;
return(nBuildDate);
}
unsigned _GenBuildDate(char *szBuildDate)
{
unsigned nReturn = 0;
char *szToken;
unsigned nYear = 0;
unsigned nMonth = 0;
unsigned nDay = 0;
if((szBuildDate) && (strchr(szBuildDate, '\\') || strchr(szBuildDate, '/')) && (szToken = strtok(szBuildDate, "\\/")))
{
nMonth = atoi(szToken);
nMonth--; /* use months in the range [0..11], as in struct tm */
if(szToken = strtok(NULL, "\\/"))
{
nDay = atoi(szToken);
if(szToken = strtok(NULL, "\\/"))
{
nYear = atoi(szToken);
if(nYear < 70) { /* handle 2 digit years like (20)00 */
nYear += 100;
}
else if (nYear < 100) {
}
else if (nYear > 1900){
nYear -= 1900;
}
}
}
}
else
{
struct tm *newtime;
time_t ltime;
time( &ltime );
/* Obtain coordinated universal time: */
newtime = gmtime( &ltime );
nYear = newtime->tm_year;
nMonth = newtime->tm_mon;
nDay = newtime->tm_mday;
}
nReturn = _CalcBuildDate(nYear, nMonth, nDay);
return(nReturn);
}
static void ShowHelp(char *szFilename)
{
char szTemp[128];
fprintf(stdout, "%s: Generates ascii format #define for FILEVERSION\n", szFilename);
fprintf(stdout, " resource identifier used by Windows executable binaries.\n");
fprintf(stdout, "\n");
fprintf(stdout, "Usage: %s <major.minor.patch> [mm/dd/yy] [outfile]\n", szFilename);
fprintf(stdout, "\n");
fprintf(stdout, "Examples:\n");
fprintf(stdout, "%s 3.0.0\n", szFilename);
fprintf(stdout, "%s 6.5.2 1/30/2001\n", szFilename);
fprintf(stdout, "%s 6.5.2 1/30/2001 fileversion.h\n", szFilename);
}
main(int nArgc, char **lpArgv)
{
int nReturn = 0;
unsigned nVersion = 0;
unsigned nBuildDate = 0;
#ifdef macintosh
nArgc = ccommand( &lpArgv );
#endif
if(nArgc < 2)
{
ShowHelp(lpArgv[0]);
nReturn = 1;
}
else
{
char *szVersion = NULL;
char *szDate = NULL;
char *szOutput = NULL;
FILE *f = stdout;
unsigned nMajor = 0;
unsigned nMinor = 0;
unsigned nPatch = 0;
szVersion = (char *)lpArgv[1];
szDate = (char *)lpArgv[2];
szOutput = (char *)lpArgv[3];
_GetVersions( szVersion, &nMajor, &nMinor, &nPatch );
nVersion = _CalcVersion(nMajor, nMinor, nPatch);
nBuildDate = _GenBuildDate(szDate);
if(nArgc >= 4) {
if (( f = fopen(szOutput, "w")) == NULL ) {
perror( szOutput );
exit( 1 );
}
}
fprintf(f, "#define VI_PRODUCTVERSION %u.%u\n", nMajor, nMinor);
fprintf(f, "#define PRODUCTTEXT \"%s\"\n", szVersion );
fprintf(f, "#define VI_FILEVERSION %u, 0, 0,%u\n",
nVersion, nBuildDate);
fprintf(f, "#define VI_FileVersion \"%s Build %u\\0\"\n",
szVersion, nBuildDate);
if(nArgc >= 4)
fclose(f);
nReturn = (nVersion && !nBuildDate);
}
return(nReturn);
}

View File

@@ -0,0 +1,23 @@
#
# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is mozilla.org LDAP SDK autoconf glue.
#
# The Initial Developer of the Original Code is Netscape
# Commmunications Corp. Portions created by Netscape are
# Copyright (C) 2000, Netscape Communications Corp. All
# Rights Reserved.
#
# Contributor(s): Dan Mosedale <dmose@mozilla.org>
#
DIST = $(DEPTH)/dist
VPATH = $(srcdir)

View File

@@ -0,0 +1,469 @@
#
# GNU Makefile for LDAP client tools.
#
LDAP_SRC = ../..
MCOM_ROOT = ../../../..
NOSTDCLEAN=true # don't let nsconfig.mk define target clean
NOSTDSTRIP=true # don't let nsconfig.mk define target strip
NSPR20=true # probably should be defined somewhere else (not sure where)
OBJDEST = $(OBJDIR)/clients/tools/obj
BINDIR = $(OBJDIR)/clients/bin
include $(MCOM_ROOT)/c-sdk/nsdefs.mk
include $(MCOM_ROOT)/c-sdk/nsconfig.mk
include $(LDAP_SRC)/nsldap.mk
ifndef LDAP_USE_OLD_DB
include $(MCOM_ROOT)/c-sdk/ns_usedb.mk
endif
# NLS Library
NLS_COMP_NAME = libnls
NLS_VERS_NUM = 31
NLS_COMP_DIR = $(NLS_COMP_NAME)$(NLS_VERS_NUM)
NLS_ROOT = $(MCOM_ROOT)/../components/$(NLS_COMP_DIR)
NLS_LIBPATH = $(NLS_ROOT)/$(NLSOBJDIR)/lib
NLS_INCLUDE = $(NLS_ROOT)/$(NLSOBJDIR)/include
NLS_LOCALE = $(NLS_ROOT)/$(NLSOBJDIR)/locale$(NLS_VERS_NUM)
NLS_CONV = $(NLS_ROOT)/$(NLSOBJDIR)/conv$(NLS_VERS_NUM)
NLS_VERSION_FILE = $(NLS_ROOT)/Version
NLS_RELDATE=v3.2
NLS_VERSION = $(NLS_RELDATE)
ifeq ($(ARCH), WINNT)
ifeq ($(OS_TARGET), WIN95)
ifeq ($(DEBUG), full)
NLSOBJDIR = WIN954.0_DBG.OBJ
else
ifeq ($(DEBUG), fulld)
NLSOBJDIR = WIN954.0_DBG.OBJD
else
NLSOBJDIR = WIN954.0_OPT.OBJ
endif
endif
else
ifeq ($(DEBUG), full)
NLSOBJDIR = WINNT4.0_DBG.OBJ
else
ifeq ($(DEBUG), fulld)
NLSOBJDIR = WINNT4.0_DBG.OBJD
else
NLSOBJDIR = WINNT4.0_OPT.OBJ
endif
endif
endif
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
# NLS_LIBNAMES = brk32$(NLS_VERS_NUM) cnv32$(NLS_VERS_NUM) col32$(NLS_VERS_NUM) fmt32$(NLS_VERS_NUM) res32$(NLS_VERS_NUM) uni32$(NLS_VERS_NUM)
NLS_LIBNAMES = cnv32$(NLS_VERS_NUM)
NLS_CONV_LIBNAMES = jpn32$(NLS_VERS_NUM) cck32$(NLS_VERS_NUM) sb32$(NLS_VERS_NUM)
NLS_LIBS = $(addsuffix .lib, $(addprefix ns, $(NLS_LIBNAMES)))
NLS_CONV_LIBS = $(addsuffix .lib, $(addprefix ns, $(NLS_CONV_LIBNAMES)))
NLSDLL_NAMES = $(addsuffix .dll, $(addprefix ns, $(NLS_LIBNAMES)))
NLS_CONVDLL_NAMES = $(addsuffix .dll, $(addprefix ns, $(NLS_CONV_LIBNAMES)))
LIBNLS = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS))
LIBNLS_CONV = $(addprefix $(NLS_LIBPATH)/, $(NLS_CONV_LIBS))
NLSOBJNAME = $(NLS_LIBNAMES)
else
ifeq ($(ARCH), HPUX)
ifeq ($(NSOS_RELEASE), B.11.00)
NLSOBJDIR = $(NSOBJDIR_NAME)
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
else
NLSOBJDIR = $(NSOBJDIR_NAME)
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
endif
else
# Here is a hack to replace _PTH with n32, this must be done before
# the _PTH substitustion
ifeq ($(ARCH),IRIX)
ifeq ($(USE_N32),1)
NLSOBJDIR = $(NSOBJDIR_NAME2_NOTAG)
else
NLSOBJDIR = $(NSOBJDIR_NAME_NOTAG)
endif
else
NLSOBJDIR = $(NSOBJDIR_NAME_NOTAG)
ifeq ($(ARCH), OSF1)
NLSOBJDIR = $(NSOBJDIR_NAME)
endif
endif
# NLS Does not has PTH version, so here is the hack which treat non PTH
# version as PTH version
ifeq ($(USE_PTHREADS), 1)
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
else
NLS_RELEASE = $(COMPONENTS_DIR)/libnls$(NLS_VERS_NUM)/$(NLS_VERSION)/$(NLSOBJDIR)
endif
endif # HPUX
NLS_LIBNAMES = cnv$(NLS_VERS_NUM)
NLS_CONV_LIBNAMES = jpn$(NLS_VERS_NUM) cck$(NLS_VERS_NUM) sb$(NLS_VERS_NUM)
NLS_SOLIB_NAMES = $(addsuffix $(DLL_PRESUF), $(addprefix libns, $(NLS_LIBNAMES)))
NLS_CONV_SOLIB_NAMES = $(addsuffix $(DLL_PRESUF), $(addprefix libns, $(NLS_CONV_LIBNAMES)))
NLS_LIBS = $(addsuffix .a, $(NLS_SOLIB_NAMES))
NLS_CONV_LIBS = $(addsuffix .a, $(NLS_CONV_SOLIB_NAMES))
NLS_SOLIBS = $(addsuffix .$(DLL_SUFFIX), $(NLS_SOLIB_NAMES))
NLS_CONV_SOLIBS = $(addsuffix .$(DLL_SUFFIX), $(NLS_CONV_SOLIB_NAMES))
NLSOBJNAME = $(NLS_SOLIBS)
LIBNLS = $(addprefix $(NLS_LIBPATH)/, $(NLS_SOLIBS))
ifeq ($(ARCH), OSF1)
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES)))) -lcxx
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS)) -lcxx
NLSLINK_CONV_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_CONV_LIBS))
else
ifeq ($(ARCH),HPUX)
#linking with libC is *BAD* on HPUX11
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES))))
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS))
NLSLINK_CONV_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_CONV_LIBS))
else
ifeq ($(ARCH),Linux)
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES)))) -lresolv -lpthread
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS)) -lresolv -lpthread
else
ifeq ($(ARCH),IRIX)
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES)))) -lpthread
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS)) -lpthread
else
NLSLINK = -L$(NLS_LIBPATH) $(addprefix -l, $(addsuffix $(DLL_PRESUF), $(addprefix ns, $(NLS_LIBNAMES)))) -lC
NLSLINK_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_LIBS)) -lC
endif # Irix
endif # Linux
NLSLINK_CONV_STATIC = $(addprefix $(NLS_LIBPATH)/, $(NLS_CONV_LIBS))
endif # HPUX
endif # OSF1
endif
ifeq ($(ARCH), SOLARIS)
NLSLINK += -lw
endif
$(LIBNLS): $(NLS_VERSION_FILE) nls_version_check
$(NLS_VERSION_FILE):
mkdir -p $(NLS_ROOT); \
cd $(NLS_ROOT); echo "garbage" > Version
ifneq ($(ARCH), WINNT)
ifndef FORCE_FTP
nls_version_check:
@if [ `cat $(NLS_VERSION_FILE)` != "$(NLS_VERSION)" -o ! -d $(NLS_ROOT)/$(NLSOBJDIR) ]; then \
if [ -d $(NLS_RELEASE) ]; then \
if [ "$(RELEASE_TREE)" != "" ]; then \
(cd $(NLS_ROOT); \
\rm -rf $(NLSOBJDIR) $(NLS_VERSION_FILE); \
ln -s $(RELEASE_TREE)/libnls31/$(NLSOBJDIR) $(NLSOBJDIR)); \
echo "$(NLS_VERSION)" > $(NLS_VERSION_FILE); \
else \
(cd $(NLS_ROOT); \
\rm -rf $(NLSOBJDIR) $(NLS_VERSION_FILE); \
ln -s $(NLS_RELEASE) $(NLSOBJDIR)); \
echo "$(NLS_VERSION)" > $(NLS_VERSION_FILE); \
fi; \
else \
echo "************************** ERROR *************************"; \
echo "LIBNLS client libraries are missing. Make sure your machine"; \
echo "has access to $(NLS_RELEASE)"; \
echo "**********************************************************"; \
exit 1; \
fi; \
fi; \
else
nls_version_check:
# The following shell script recalculates $(NLS_INCLUDE), $(NLS_LIBPATH) and
# $(NLS_VERSION_FILE)
sh $(MCOM_ROOT)/c-sdk/compver.sh $(NLS_ROOT) $(NLS_VERSION) \
$(NLSOBJDIR) $(MCOM_ROOT) $(MODULE) $(NLS_RELEASE) libnls$(NLS_VERS_NUM) \
"' include lib conv$(NLS_VERS_NUM) locale$(NLS_VERS_NUM) '" $(NLS_ROOT)/$(NLSOBJDIR)/locale$(NLS_VERS_NUM)/index.txt
endif
else
nls_version_check:
# The following shell script recalculates $(NLS_INCLUDE), $(NLS_LIBPATH) and
# $(NLS_VERSION_FILE)
sh $(MCOM_ROOT)/c-sdk/compver.sh $(NLS_ROOT) $(NLS_VERSION) \
$(NLSOBJDIR) $(MCOM_ROOT) ldapsdk $(NLS_RELEASE) \
libnls$(NLS_VERS_NUM) \
"' include lib conv$(NLS_VERS_NUM) locale$(NLS_VERS_NUM) '" \
$(NLS_ROOT)/$(NLSOBJDIR)/locale$(NLS_VERS_NUM)/index.txt
endif
ifeq ($(ARCH), HPUX)
ifeq ($(NSOS_RELEASE), B.11.00)
EXTRA_LIBS += -lrt
CXX=aCC -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L
LINK_EXE_NOLIBSOBJS_NOCXX = $(CXX) -Wl,-E $(ALDFLAGS) $(LDFLAGS) \
$(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@
LINK_EXE_NOCXX = $(CXX) -Wl,-E $(ALDFLAGS) $(LDFLAGS) \
$(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(OBJS) $(EXTRA_LIBS)
endif
ifeq ($(NSOS_RELEASE), B.11.00_64)
EXTRA_LIBS += -lrt
CXX=aCC -DHPUX_ACC -D__STDC_EXT__ -D_POSIX_C_SOURCE=199506L +DA2.0W +DS2.0
LINK_EXE_NOLIBSOBJS_NOCXX = $(CXX) -Wl,-E $(ALDFLAGS) $(LDFLAGS) \
$(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@
LINK_EXE_NOCXX = $(CXX) -Wl,-E $(ALDFLAGS) $(LDFLAGS) \
$(RPATHFLAG_PREFIX)$(RPATHFLAG) -o $@ $(OBJS) $(EXTRA_LIBS)
endif
ifeq ($(NSOS_RELEASE), B.10.10)
CC= CC +a1
# CXX=CC -D__STDC_EXT__
# $(subst "+e", "",$(CFLAGS))
endif
endif
ifeq ($(ARCH),Linux)
CXX = egcs
LINK_EXE = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
$(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) \
-o $@ $(OBJS) $(EXTRA_LIBS)
LINK_EXE_NOLIBSOBJS = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
$(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) -o $@
else
ifeq ($(ARCH), OSF1)
ifdef USE_LD_RUN_PATH
#does RPATH differently. instead we export RPATHFLAG as LD_RUN_PATH
#see ns/c-sdk/ldap/clients/tools/Makefile for an example
export LD_RUN_PATH=$(RPATHFLAG)
LINK_EXE = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
-o $@ $(OBJS) $(EXTRA_LIBS)
LINK_EXE_NOLIBSOBJS = $(CXX) $(ALDFLAGS) $(LDFLAGS) -o $@
else # USE_LD_RUN_PATH
LINK_EXE = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
$(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) \
-o $@ $(OBJS) $(EXTRA_LIBS)
LINK_EXE_NOLIBSOBJS = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
$(RPATHFLAG_PREFIX)$(RPATHFLAG)$(RPATHFLAG_EXTRAS) -o $@
endif # USE_LD_RUN_PATH
endif
endif
MCOM_INCLUDE += -I$(NLS_INCLUDE)
INCLUDES += $(SSLINCLUDE) $(NO_LIBLCACHE)
DEFS += $(SSL)
ALDFLAGS += $(SSLLIBFLAG)
ifeq ($(ARCH), WINNT)
SUBSYSTEM=console
endif
ifneq ($(ARCH), WINNT)
# Run-time search path for shared libraries: in admin server 3.x installations,
# the ldap tools get installed under NSHOME/userdb/ldap/tools and the LDAP SDK
# libraries (libldap and liblcache) get installed under NSHOME/lib, so the
# correct library search path is ../../../lib. We also want to search
# NSHOME/bin/slapd, where more recent versions of the SDK so's may be.
RPATHFLAG=..:../lib:../../lib:../../../lib:../../../../lib
ifdef USE_LD_RUN_PATH
LD_RUN_PATH=$(RPATHFLAG)
export LD_RUN_PATH
endif
endif
# svrcore is used by ntpinobj, and pinarg handling
LIBSVRCORE_DEP= $(NSCP_DISTDIR)/lib/svrcore.$(LIB_SUFFIX)
ifeq ($(ARCH), WINNT)
LIBSVRCORE= $(NSCP_DISTDIR)/lib/svrcore.$(LIB_SUFFIX)
else
LIBSVRCORE = -lsvrcore
endif
ifeq ($(INCLUDE_SSL),1)
# libsec and friends are already in libldap, so don't link with them here
LDTOOLS_LIBS_DEP = $(LDAP_SDK_LIBLDAP_DLL_DEP) $(EXTRA_LIBS_DEP)
LDTOOLS_LIBS = $(LDAP_SDK_LIBLDAP_DLL)
ifneq ($(LDAP_NO_LIBLCACHE),1)
LDTOOLS_LIBS_DEP += $(LDAP_LIBLDIF_DEP)
LDTOOLS_LIBS += $(LDAP_LIBLDIF) $(LDAP_SDK_LIBLCACHE_DLL)
else
LDTOOLS_LIBS_DEP += $(LDAP_LIBLDIF_DEP)
LDTOOLS_LIBS += $(LDAP_LIBLDIF)
endif
LDTOOLS_LIBS += $(EXTRA_LIBS) $(EXTRA_MALLOC_LIBS) $(LDAP_SDK_LIBLDAP_DLL) $(LIBSVRCORE)
# XXXceb The linker on NT is auto optimizing. We still need to have libsec around for svrcore
# Do Not Mess with the link order. This was not straightforward, and "optimizing" the text
# will break the builds.
ifeq ($(ARCH), WINNT)
LDTOOLS_LIBS += $(LIBSEC)
endif
ifeq ($(ARCH), SOLARIS)
LDTOOLS_LIBS += $(LIBSEC) $(LIBDB)
endif
ifeq ($(ARCH), HPUX)
LDTOOLS_LIBS += $(LIBSEC)
endif
ifeq ($(ARCH), IRIX)
LDTOOLS_LIBS += $(LIBSEC) $(LIBDB)
endif
ifeq ($(ARCH), AIX)
LDTOOLS_LIBS += $(LIBSEC) $(LIBDB)
endif
ifeq ($(ARCH), WINNT)
LDTOOLS_LIBS += $(LIBNSPR)
else
LDTOOLS_LIBS += $(DYNAMICNSPR)
endif
else
# SSL is not included in the LDAP shared library...
# need to link with libsec and friends explicitly
LDTOOLS_LIBS_DEP = $(LDAP_SDK_LIBS_DEP) $(LDAP_LIBLDIF_DEP) \
$(EXTRA_LIBS_DEP)
LDTOOLS_LIBS_DEP += $(LDAP_LIBLDIF_DEP)
ifeq ($(ARCH), OSF1)
LDTOOLS_LIBS = $(LDAP_SDK_LIBSSLDAP_LIB) $(LDAP_SDK_LIBLDAP_DLL) $(LDAP_SDK_LIBPRLDAP_DLL)
else
LDTOOLS_LIBS = $(LDAP_SDK_LIBSSLDAP_LIB) $(LDAP_SDK_LIBPRLDAP_DLL) $(LDAP_SDK_LIBLDAP_DLL)
endif
ifneq ($(LDAP_NO_LIBLCACHE),1)
LDTOOLS_LIBS += $(LDAP_SDK_LIBLCACHE_DLL)
endif
LDTOOLS_LIBS += $(LIBSVRCORE) $(LIBSEC) $(LIBDB) $(EXTRA_LIBS)\
$(EXTRA_MALLOC_LIBS) $(LDAP_LIBLDIF)
ifneq ($(LDAP_NO_LIBLCACHE),1)
ifndef LDAP_USE_OLD_DB
LDTOOLS_LIBS_DEP+=$(DB_LIB_DEP)
LDTOOLS_LIBS+=$(DB_LIB)
endif
endif
ifeq ($(LDAP_NO_LIBLCACHE),1)
CFLAGS+=-DNO_LIBLCACHE
endif
ifeq ($(ARCH), WINNT)
LDTOOLS_LIBS += $(LIBNSPR)
else
LDTOOLS_LIBS += $(DYNAMICNSPR)
endif
# INCLUDE_SSL
endif
LDTOOLS_LIBS_DEP += $(LIBNLS)
ifeq ($(ARCH), WINNT)
LDTOOLS_LIBS += $(LIBNLS) $(LIBNLS_CONV)
else
LDTOOLS_LIBS += $(NLSLINK_STATIC) $(NLSLINK_CONV_STATIC)
endif
#LDTOOLS_LIBS += $(LIBSVRCORE)
ifeq ($(ARCH), AIX)
LDTOOLS_LIBS += $(EXE_EXTRA_LIBS)
endif
ifeq ($(ARCH), WINNT)
ALDFLAGS += -FORCE:MULTIPLE /NODEFAULTLIB:MSVCRTD
endif
#ifeq ($(ARCH), HPUX)
#CC=CC +a1
#LINK_EXE = $(LINK_EXE_NOCXX)
#endif
ifeq ($(ARCH),IRIX)
ifeq ($(USE_N32),1)
CXX=CC
LDFLAGS += -n32 -mips3
CC=cc
LINK_EXE = $(CXX) $(ALDFLAGS) $(LDFLAGS) \
-o $@ $(OBJS) $(EXTRA_LIBS)
endif
endif
ifeq ($(ARCH), SOLARIS)
ifeq ($(USE_64), 1)
LINK_EXE += -xarch=v9 -L/usr/lib/sparcv9 -lCrun
else
LINK_EXE += -xarch=v8
endif
endif
LINK_EXE += -$(LIBPATH)../$(MCOM_ROOT)/dist/$(NC_BUILD_FLAVOR)/lib
LDAPDELETE_OBJ = $(addprefix $(OBJDEST)/, ldapdelete.o)
LDAPMODIFY_OBJ = $(addprefix $(OBJDEST)/, ldapmodify.o fileurl.o)
LDAPMODRDN_OBJ = $(addprefix $(OBJDEST)/, ldapmodrdn.o)
LDAPSEARCH_OBJ = $(addprefix $(OBJDEST)/, ldapsearch.o fileurl.o)
LDAPCMP_OBJ = $(addprefix $(OBJDEST)/, ldapcmp.o)
LDAPTOOLCOMMON_OBJ = $(addprefix $(OBJDEST)/, common.o convutf8.o argpin.o ntuserpin.o)
CLIENT_OBJS = $(LDAPDELETE_OBJ) $(LDAPMODIFY_OBJ) $(LDAPMODRDN_OBJ) \
$(LDAPSEARCH_OBJ) $(LDAPCMP_OBJ) $(LDAPTOOLCOMMON_OBJ)
LDAPDELETE = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapdelete))
LDAPMODIFY = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapmodify))
LDAPMODRDN = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapmodrdn))
LDAPSEARCH = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapsearch))
LDAPADD = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapadd))
LDAPCMP = $(addsuffix $(EXE_SUFFIX), $(addprefix $(BINDIR)/, ldapcmp))
BINS= $(LDAPDELETE) $(LDAPMODIFY) $(LDAPSEARCH) $(LDAPCMP)
all: $(OBJDEST) $(BINDIR) $(BINS)
cmp: $(LDAPCMP)
$(LDAPTOOLCOMMON_OBJ): $(LIBNLS)
$(LDAPDELETE): $(LDAPDELETE_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
$(LINK_EXE) $(LDAPDELETE_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
$(LDAPMODIFY): $(LDAPMODIFY_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
$(LINK_EXE) $(LDAPMODIFY_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
$(LDAPMODRDN): $(LDAPMODRDN_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
$(LINK_EXE) $(LDAPMODRDN_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
$(LDAPSEARCH): $(LDAPSEARCH_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
$(LINK_EXE) $(LDAPSEARCH_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
$(LDAPADD): $(LDAPMODIFY) $(LDTOOLS_LIBS_DEP)
$(RM) $(LDAPADD)
$(HARDLN) $(LDAPMODIFY) $(LDAPADD)
$(LDAPCMP): $(LDAPCMP_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS_DEP)
$(LINK_EXE) $(LDAPCMP_OBJ) $(LDAPTOOLCOMMON_OBJ) $(LDTOOLS_LIBS)
clientSDK: all
$(OBJDEST):
$(MKDIR) $(OBJDEST)
$(BINDIR):
$(MKDIR) $(BINDIR)
clean:
$(RM) $(CLIENT_OBJS)
$(RM) $(BINS)
#
# Simple, local dependencies
#
LDAPTOOL_COMMON_DEPS = ldaptool.h Makefile
$(LDAPTOOLCOMMON_OBJ): $(LDAPTOOL_COMMON_DEPS)
$(LDAPDELETE_OBJ): $(LDAPTOOL_COMMON_DEPS)
$(LDAPMODIFY_OBJ): $(LDAPTOOL_COMMON_DEPS) fileurl.h
$(LDAPMODRDN_OBJ): $(LDAPTOOL_COMMON_DEPS)
$(LDAPSEARCH_OBJ): $(LDAPTOOL_COMMON_DEPS) fileurl.h
$(LDAPCMP_OBJ): $(LDAPTOOL_COMMON_DEPS)

View File

@@ -0,0 +1,53 @@
Summary of options used by the LDAP tools
Updated 5-May-2000 by Mark Smith <mcs@netscape.com>
Only single letter options in the sets [0-9], [A-Z], and [a-z] are
listed.
The "raw" lists are taken from the calls to getopt() and
ldaptool_process_args().
The "sorted" lists are just that -- sorted versions of the raw list.
The "all" lists include options from common.c as well as the tool-specific
options.
The "avail" lists included options that are available for use.
common.c (supported by all of the tools):
raw: nvEMRHZ0d:D:f:h:I:K:N:O:P:p:Q:W:w:V:X:m:i:k:y:
sorted: 0 DEHIKMNOPQRVWXZ dfhikmnpvwy
avail: [2-9] CJY gj (not used by any of the tools)
ldapcmp.c:
raw: Bb:l:s:z:
sorted: B blsz
all: 0 BDHIKMNOPQRVWXZ bdfhiklmnpsvwyz
avail: [1-9] ACFGJLSTU acegjoqrtu
ldapdelete.c (deprecated)
raw: c
sorted: c
all: 0 DHIKMNOPQRVWXZ cdfhikmnpvwy
avail: [1-9] ABCFGJLSTUY abegjloqrstuxz
ldapmodify.c
raw: aAbcFe:B:q
sorted: ABF abceq
all: 0 ABDFHIKMNOPQRVWXZ abcdefhikmnpqvwy
avail: [1-9] CGJLSTUY gjlorstuxz
ldapmodrdn.c (deprecated)
raw: cr
sorted: cr
all: 0 DHIKMNOPQRVWXZ cdfhikmnprvwy
avail: [1-9] ABCFGJLSTUY abegjloqstuxz
ldapsearch.c
raw: ABLTU1eotuxa:b:F:G:l:S:s:z:
sorted: 1 ABFGLSTU abeostuxz
all: 01 ABDFGHIKLMNOPQRSTUVWXZ abdefhikmnopstuvwxyz
avail: [2-9] CJY cgjlqr

View File

@@ -0,0 +1,129 @@
/******************************************************
*
* Copyright (c) 1996 Netscape Communications Corp.
* This code is proprietary and is a trade secret of
* Netscape Communications Corp.
*
* argpin.c - Returns pin for token specified in a
* command line paramenter.
*
******************************************************/
#include <stdio.h>
#include <string.h>
#include "argpin.h"
struct SVRCOREArgPinObj
{
SVRCOREPinObj base;
char *tokenName;
char *password;
SVRCOREPinObj *alt;
};
static const struct SVRCOREPinMethods vtable;
/* XXXceb these are two hacks to fix a problem with the debug builds
* of svrcore. With the optimizer turned off, there is a situation
* in user.c, where these two functions need to be available for the
* linker (they are imported, and no lib exports them, since they are
* declared static on XP_UNIX platforms) The short term hack solution
* is to define them here. Yeah, it is ugly but, it will need to be
* here, until a new version of svrcore is done.
*/
void echoOff(int fd)
{
}
void echoOn(int fd)
{
}
/* ------------------------------------------------------------ */
SVRCOREError
SVRCORE_CreateArgPinObj(SVRCOREArgPinObj **out, const char * tokenName, const char *password, SVRCOREPinObj *pinObj)
{
SVRCOREError err = 0;
SVRCOREArgPinObj *obj = 0;
do {
obj = (SVRCOREArgPinObj*)malloc(sizeof (SVRCOREArgPinObj));
if (!obj) { err = 1; break; }
obj->base.methods = &vtable;
obj->tokenName=NULL;
obj->password=NULL;
obj->alt=pinObj;
if ( tokenName == NULL) {
PK11SlotInfo *slot = PK11_GetInternalKeySlot();
obj->tokenName = strdup(PK11_GetTokenName(slot));
PK11_FreeSlot(slot);
}
else
{
obj->tokenName = strdup(tokenName);
}
if (obj->tokenName == NULL) { err = 1; break; }
obj->password = strdup(password);
if (obj->password == NULL) { err = 1; break; }
} while(0);
if (err)
{
SVRCORE_DestroyArgPinObj(obj);
obj = 0;
}
*out = obj;
return err;
}
void
SVRCORE_DestroyArgPinObj(SVRCOREArgPinObj *obj)
{
if (obj->tokenName) free(obj->tokenName);
if (obj->password)
{
memset(obj->password, 0, strlen(obj->password));
free(obj->password);
}
if (obj) free(obj);
}
static void destroyObject(SVRCOREPinObj *obj)
{
SVRCORE_DestroyArgPinObj((SVRCOREArgPinObj*)obj);
}
static char *getPin(SVRCOREPinObj *obj, const char *tokenName, PRBool retry)
{
SVRCOREArgPinObj *p = (SVRCOREArgPinObj*)obj;
if (tokenName == NULL) return NULL;
/* On first attempt, return the password if the token name
* matches.
*/
if (!retry && strcmp(p->tokenName, tokenName) == 0)
{
return strdup(p->password);
}
if (p->alt != NULL) return SVRCORE_GetPin(p->alt, tokenName, retry);
return (NULL);
}
/*
* VTable
*/
static const SVRCOREPinMethods vtable =
{ 0, 0, destroyObject, getPin };

View File

@@ -0,0 +1,14 @@
#ifndef __ARGPIN_H__
#define __ARGPIN_H__
#include <svrcore.h>
typedef struct SVRCOREArgPinObj SVRCOREArgPinObj;
SVRCOREError
SVRCORE_CreateArgPinObj(SVRCOREArgPinObj **out, const char * tokenName, const char *password, SVRCOREPinObj *pinObj);
void
SVRCORE_DestroyArgPinObj(SVRCOREArgPinObj *obj);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,536 @@
#include <stdio.h>
#include <string.h>
#ifdef XP_WIN32
#define VC_EXTRALEAN
#include <afxwin.h>
#include <winnls.h>
#endif
extern char *ldaptool_charset;
static int charsetset = 0;
extern "C" {
char *ldaptool_convdir = NULL;
char *ldaptool_local2UTF8( const char * );
}
#ifndef XP_WIN32
char * GetNormalizedLocaleName(void);
#include "unistring.h"
#include "nlsenc.h"
extern NLS_StaticConverterRegistry _STATICLINK_NSJPN_;
extern NLS_StaticConverterRegistry _STATICLINK_NSCCK_;
extern NLS_StaticConverterRegistry _STATICLINK_NSSB_;
char *
GetNormalizedLocaleName(void)
{
#ifdef _HPUX_SOURCE
int len;
char *locale;
locale = setlocale(LC_CTYPE, "");
if (locale && *locale) {
len = strlen(locale);
} else {
locale = "C";
len = 1;
}
if ((!strncmp(locale, "/\x03:", 3)) &&
(!strcmp(&locale[len - 2], ";/"))) {
locale += 3;
len -= 5;
}
locale = strdup(locale);
if (locale) {
locale[len] = 0;
}
return locale;
#else
char *locale;
locale = setlocale(LC_CTYPE, "");
if (locale && *locale) {
return strdup(locale);
}
return strdup("C");
#endif
}
#if defined(IRIX)
const char *CHARCONVTABLE[] =
{
"! This table maps the host's locale names to LIBNLS charsets",
"!",
"C: ISO_8859-1:1987",
"cs: ISO_8859-2:1987",
"da: ISO_8859-1:1987",
"de: ISO_8859-1:1987",
"de_AT: ISO_8859-1:1987",
"de_CH: ISO_8859-1:1987",
"en: ISO_8859-1:1987",
"en_AU: ISO_8859-1:1987",
"en_CA: ISO_8859-1:1987",
"en_TH: ISO_8859-1:1987",
"en_US: ISO_8859-1:1987",
"es: ISO_8859-1:1987",
"fi: ISO_8859-1:1987",
"fr: ISO_8859-1:1987",
"fr_BE: ISO_8859-1:1987",
"fr_CA: ISO_8859-1:1987",
"fr_CH: ISO_8859-1:1987",
"is: ISO_8859-1:1987",
"it: ISO_8859-1:1987",
"it_CH: ISO_8859-1:1987",
"ja_JP.EUC: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ko_KR.euc: EUC-KR",
"nl: ISO_8859-1:1987",
"nl_BE: ISO_8859-1:1987",
"no: ISO_8859-1:1987",
"pl: ISO_8859-2:1987",
"pt: ISO_8859-1:1987",
"sh: ISO_8859-2:1987",
"sk: ISO_8859-2:1987",
"sv: ISO_8859-1:1987",
"zh_CN.ugb: GB2312",
"zh_TW.ucns: cns11643_1",
NULL
};
#elif defined(SOLARIS)
const char *CHARCONVTABLE[] =
{
"! This table maps the host's locale names to LIBNLS charsets",
"!",
"C: ISO_8859-1:1987",
"ja: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ja_JP.EUC: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ja_JP.PCK: Shift_JIS",
"en: ISO_8859-1:1987",
"en_AU: ISO_8859-1:1987",
"en_CA: ISO_8859-1:1987",
"en_UK: ISO_8859-1:1987",
"en_US: ISO_8859-1:1987",
"es: ISO_8859-1:1987",
"es_AR: ISO_8859-1:1987",
"es_BO: ISO_8859-1:1987",
"es_CL: ISO_8859-1:1987",
"es_CO: ISO_8859-1:1987",
"es_CR: ISO_8859-1:1987",
"es_EC: ISO_8859-1:1987",
"es_GT: ISO_8859-1:1987",
"es_MX: ISO_8859-1:1987",
"es_NI: ISO_8859-1:1987",
"es_PA: ISO_8859-1:1987",
"es_PE: ISO_8859-1:1987",
"es_PY: ISO_8859-1:1987",
"es_SV: ISO_8859-1:1987",
"es_UY: ISO_8859-1:1987",
"es_VE: ISO_8859-1:1987",
"fr: ISO_8859-1:1987",
"fr_BE: ISO_8859-1:1987",
"fr_CA: ISO_8859-1:1987",
"fr_CH: ISO_8859-1:1987",
"de: ISO_8859-1:1987",
"de_AT: ISO_8859-1:1987",
"de_CH: ISO_8859-1:1987",
"nl: ISO_8859-1:1987",
"nl_BE: ISO_8859-1:1987",
"it: ISO_8859-1:1987",
"sv: ISO_8859-1:1987",
"no: ISO_8859-1:1987",
"da: ISO_8859-1:1987",
"iso_8859_1: ISO_8859-1:1987",
"japanese: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ko: EUC-KR",
"zh: GB2312",
"zh_TW: cns11643_1",
NULL
};
#elif defined(OSF1)
const char *CHARCONVTABLE[] =
{
"! This table maps the host's locale names to LIBNLS charsets",
"!",
"C: ISO_8859-1:1987",
"cs_CZ.ISO8859-2: ISO_8859-2:1987",
"cs_CZ: ISO_8859-2:1987",
"da_DK.ISO8859-1: ISO_8859-1:1987",
"de_CH.ISO8859-1: ISO_8859-1:1987",
"de_DE.ISO8859-1: ISO_8859-1:1987",
"en_GB.ISO8859-1: ISO_8859-1:1987",
"en_US.ISO8859-1: ISO_8859-1:1987",
"es_ES.ISO8859-1: ISO_8859-1:1987",
"fi_FI.ISO8859-1: ISO_8859-1:1987",
"fr_BE.ISO8859-1: ISO_8859-1:1987",
"fr_CA.ISO8859-1: ISO_8859-1:1987",
"fr_CH.ISO8859-1: ISO_8859-1:1987",
"fr_FR.ISO8859-1: ISO_8859-1:1987",
"hu_HU.ISO8859-2: ISO_8859-2:1987",
"hu_HU: ISO_8859-2:1987",
"is_IS.ISO8859-1: ISO_8859-1:1987",
"it_IT.ISO8859-1: ISO_8859-1:1987",
"ja_JP.SJIS: Shift_JIS",
"ja_JP.eucJP: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ja_JP: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ko_KR.eucKR: EUC-KR",
"ko_KR: EUC-KR",
"nl_BE.ISO8859-1: ISO_8859-1:1987",
"nl_NL.ISO8859-1: ISO_8859-1:1987",
"no_NO.ISO8859-1: ISO_8859-1:1987",
"pl_PL.ISO8859-2: ISO_8859-2:1987",
"pl_PL: ISO_8859-2:1987",
"pt_PT.ISO8859-1: ISO_8859-1:1987",
"sk_SK.ISO8859-2: ISO_8859-2:1987",
"sk_SK: ISO_8859-2:1987",
"sv_SE.ISO8859-1: ISO_8859-1:1987",
"zh_CN: GB2312",
"zh_HK.big5: Big5",
"zh_HK.eucTW: cns11643_1",
"zh_TW.big5: Big5",
"zh_TW.big5@chuyin: Big5",
"zh_TW.big5@radical: Big5",
"zh_TW.big5@stroke: Big5",
"zh_TW.eucTW: cns11643_1",
"zh_TW.eucTW@chuyin: cns11643_1",
"zh_TW.eucTW@radical: cns11643_1",
"zh_TW.eucTW@stroke: cns11643_1",
"zh_TW: cns11643_1",
NULL
};
#elif defined(HPUX)
const char *CHARCONVTABLE[] =
{
"! This table maps the host's locale names to LIBNLS charsets",
"!",
"C: ISO_8859-1:1987",
"ja_JP: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ja_JP.SJIS: Shift_JIS",
"ja_JP.eucJP: Extended_UNIX_Code_Packed_Format_for_Japanese",
"es_ES: ISO_8859-1:1987",
"es_ES.iso88591: ISO_8859-1:1987",
"sv_SE: ISO_8859-1:1987",
"sv_SE.iso88591: ISO_8859-1:1987",
"da_DK: ISO_8859-1:1987",
"da_DK.iso88591: ISO_8859-1:1987",
"nl_NL: ISO_8859-1:1987",
"nl_NL.iso88591: ISO_8859-1:1987",
"en: ISO_8859-1:1987",
"en_GB: ISO_8859-1:1987",
"en_GB.iso88591: ISO_8859-1:1987",
"en_US: ISO_8859-1:1987",
"en_US.iso88591: ISO_8859-1:1987",
"fi_FI: ISO_8859-1:1987",
"fi_FI.iso88591: ISO_8859-1:1987",
"fr_CA: ISO_8859-1:1987",
"fr_CA.iso88591: ISO_8859-1:1987",
"fr_FR: ISO_8859-1:1987",
"fr_FR.iso88591: ISO_8859-1:1987",
"de_DE: ISO_8859-1:1987",
"de_DE.iso88591: ISO_8859-1:1987",
"is_IS: ISO_8859-1:1987",
"is_IS.iso88591: ISO_8859-1:1987",
"it_IT: ISO_8859-1:1987",
"it_IT.iso88591: ISO_8859-1:1987",
"no_NO: ISO_8859-1:1987",
"no_NO.iso88591: ISO_8859-1:1987",
"pt_PT: ISO_8859-1:1987",
"pt_PT.iso88591: ISO_8859-1:1987",
"hu_HU: ISO_8859-2:1987",
"hu_HU.iso88592: ISO_8859-2:1987",
"cs_CZ: ISO_8859-2:1987",
"cs_CZ.iso88592: ISO_8859-2:1987",
"pl_PL: ISO_8859-2:1987",
"pl_PL.iso88592: ISO_8859-2:1987",
"ro_RO: ISO_8859-2:1987",
"ro_RO.iso88592: ISO_8859-2:1987",
"hr_HR: ISO_8859-2:1987",
"hr_HR.iso88592: ISO_8859-2:1987",
"sk_SK: ISO_8859-2:1987",
"sk_SK.iso88592: ISO_8859-2:1987",
"sl_SI: ISO_8859-2:1987",
"sl_SI.iso88592: ISO_8859-2:1987",
"american.iso88591: ISO_8859-1:1987",
"bulgarian: ISO_8859-2:1987",
"c-french.iso88591: ISO_8859-1:1987",
"chinese-s: GB2312",
"chinese-t.big5: Big5",
"czech: ISO_8859-2:1987",
"danish.iso88591: ISO_8859-1:1987",
"dutch.iso88591: ISO_8859-1:1987",
"english.iso88591: ISO_8859-1:1987",
"finnish.iso88591: ISO_8859-1:1987",
"french.iso88591: ISO_8859-1:1987",
"german.iso88591: ISO_8859-1:1987",
"hungarian: ISO_8859-2:1987",
"icelandic.iso88591: ISO_8859-1:1987",
"italian.iso88591: ISO_8859-1:1987",
"japanese.euc: Extended_UNIX_Code_Packed_Format_for_Japanese",
"japanese: Shift_JIS",
"katakana: Shift_JIS",
"korean: EUC-KR",
"norwegian.iso88591: ISO_8859-1:1987",
"polish: ISO_8859-2:1987",
"portuguese.iso88591: ISO_8859-1:1987",
"rumanian: ISO_8859-2:1987",
"serbocroatian: ISO_8859-2:1987",
"slovene: ISO_8859-2:1987",
"spanish.iso88591: ISO_8859-1:1987",
"swedish.iso88591: ISO_8859-1:1987",
NULL
};
#elif defined(AIX)
const char *CHARCONVTABLE[] =
{
"! This table maps the host's locale names to LIBNLS charsets",
"!",
"C: ISO_8859-1:1987",
"En_JP.IBM-932: Shift_JIS",
"En_JP: Shift_JIS",
"Ja_JP.IBM-932: Shift_JIS",
"Ja_JP: Shift_JIS",
"da_DK.ISO8859-1: ISO_8859-1:1987",
"da_DK: ISO_8859-1:1987",
"de_CH.ISO8859-1: ISO_8859-1:1987",
"de_CH: ISO_8859-1:1987",
"de_DE.ISO8859-1: ISO_8859-1:1987",
"de_DE: ISO_8859-1:1987",
"en_GB.ISO8859-1: ISO_8859-1:1987",
"en_GB: ISO_8859-1:1987",
"en_JP.IBM-eucJP: Extended_UNIX_Code_Packed_Format_for_Japanese",
"en_JP: Extended_UNIX_Code_Packed_Format_for_Japanese",
"en_KR.IBM-eucKR: EUC-KR",
"en_KR: EUC-KR",
"en_TW.IBM-eucTW: cns11643_1",
"en_TW: cns11643_1",
"en_US.ISO8859-1: ISO_8859-1:1987",
"en_US: ISO_8859-1:1987",
"es_ES.ISO8859-1: ISO_8859-1:1987",
"es_ES: ISO_8859-1:1987",
"fi_FI.ISO8859-1: ISO_8859-1:1987",
"fi_FI: ISO_8859-1:1987",
"fr_BE.ISO8859-1: ISO_8859-1:1987",
"fr_BE: ISO_8859-1:1987",
"fr_CA.ISO8859-1: ISO_8859-1:1987",
"fr_CA: ISO_8859-1:1987",
"fr_CH.ISO8859-1: ISO_8859-1:1987",
"fr_CH: ISO_8859-1:1987",
"fr_FR.ISO8859-1: ISO_8859-1:1987",
"fr_FR: ISO_8859-1:1987",
"is_IS.ISO8859-1: ISO_8859-1:1987",
"is_IS: ISO_8859-1:1987",
"it_IT.ISO8859-1: ISO_8859-1:1987",
"it_IT: ISO_8859-1:1987",
"ja_JP.IBM-eucJP: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ja_JP: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ko_KR.IBM-eucKR: EUC-KR",
"ko_KR: EUC-KR",
"nl_BE.ISO8859-1: ISO_8859-1:1987",
"nl_BE: ISO_8859-1:1987",
"nl_NL.ISO8859-1: ISO_8859-1:1987",
"nl_NL: ISO_8859-1:1987",
"no_NO.ISO8859-1: ISO_8859-1:1987",
"no_NO: ISO_8859-1:1987",
"pt_PT.ISO8859-1: ISO_8859-1:1987",
"pt_PT: ISO_8859-1:1987",
"sv_SE.ISO8859-1: ISO_8859-1:1987",
"sv_SE: ISO_8859-1:1987",
"zh_TW.IBM-eucTW: cns11643_1",
"zh_TW: cns11643_1",
NULL
};
#else // sunos by default
const char *CHARCONVTABLE[] =
{
"! This table maps the host's locale names to LIBNLS charsets",
"!",
"C: ISO_8859-1:1987",
"de: ISO_8859-1:1987",
"en_US: ISO_8859-1:1987",
"es: ISO_8859-1:1987",
"fr: ISO_8859-1:1987",
"iso_8859_1: ISO_8859-1:1987",
"it: ISO_8859-1:1987",
"ja: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ja_JP.EUC: Extended_UNIX_Code_Packed_Format_for_Japanese",
"japanese: Extended_UNIX_Code_Packed_Format_for_Japanese",
"ko: EUC-KR",
"sv: ISO_8859-1:1987",
"zh: GB2312",
"zh_TW: cns11643_1",
NULL
};
#endif
#define BSZ 256
char *
GetCharsetFromLocale(char *locale)
{
char *tmpcharset = NULL;
char buf[BSZ];
char *p;
const char *line;
int i=0;
line = CHARCONVTABLE[i];
while (line != NULL)
{
if (*line == 0)
{
break;
}
strcpy(buf, line);
line = CHARCONVTABLE[++i];
if (strlen(buf) == 0 || buf[0] == '!')
{
continue;
}
p = strchr(buf, ':');
if (p == NULL)
{
tmpcharset = NULL;
break;
}
*p = 0;
if (strcmp(buf, locale) == 0) {
while (*++p == ' ' || *p == '\t')
;
if (isalpha(*p)) {
tmpcharset = strdup(p);
} else
tmpcharset = NULL;
break;
}
}
return tmpcharset;
}
#endif /* Not defined XP_WIN32 */
#ifdef XP_WIN32
char *_convertor(const char *instr, int bFromUTF8)
{
char *outstr = NULL;
int inlen, wclen, outlen;
LPWSTR wcstr;
if (instr == NULL)
return NULL;
if ((inlen = strlen(instr)) <= 0)
return NULL;
/* output never becomes longer than input,
** thus we don't have to ask for the length
*/
wcstr = (LPWSTR) malloc( sizeof( WCHAR ) * (inlen+1) );
if (!wcstr)
return NULL;
wclen = MultiByteToWideChar(bFromUTF8 ? CP_UTF8 : CP_ACP, 0, instr,
inlen, wcstr, inlen);
outlen = WideCharToMultiByte(bFromUTF8 ? CP_ACP : CP_UTF8, 0, wcstr,
wclen, NULL, 0, NULL, NULL);
if (outlen > 0) {
outstr = (char *) malloc(outlen + 2);
outlen = WideCharToMultiByte(bFromUTF8 ? CP_ACP : CP_UTF8, 0, wcstr,
wclen, outstr, outlen, NULL, NULL);
if (outlen > 0)
*(outstr+outlen) = _T('\0');
else
return NULL;
}
free( wcstr );
return outstr;
}
#endif
char *
ldaptool_local2UTF8( const char *src )
{
char *utf8;
#ifndef XP_WIN32
char *locale, *newcharset;
size_t outLen, resultLen;
NLS_ErrorCode err;
if (src == NULL)
{
return NULL;
}
else if (*src == 0)
{
utf8 = strdup(src);
return utf8;
}
if( (ldaptool_charset != NULL) && (!strcmp( ldaptool_charset, "" ))
&& (!charsetset) )
{
locale = GetNormalizedLocaleName();
ldaptool_charset = GetCharsetFromLocale(locale);
free( locale );
charsetset = 1;
}
else
if( (ldaptool_charset != NULL) && strcmp( ldaptool_charset, "" )
&& (!charsetset) )
{
newcharset = GetCharsetFromLocale( ldaptool_charset );
free( ldaptool_charset );
ldaptool_charset = newcharset;
charsetset = 1;
}
if (ldaptool_charset == NULL) {
return strdup(src);
}
if (NLS_EncInitialize(NULL, ldaptool_convdir) != NLS_SUCCESS ||
NLS_RegisterStaticLibrary(_STATICLINK_NSJPN_) != NLS_SUCCESS ||
NLS_RegisterStaticLibrary(_STATICLINK_NSCCK_) != NLS_SUCCESS ||
NLS_RegisterStaticLibrary(_STATICLINK_NSSB_) != NLS_SUCCESS) {
return strdup(src);
}
outLen = NLS_GetResultBufferSize( (byte *) src,
strlen( src ) * sizeof(char),
ldaptool_charset,
NLS_ENCODING_UTF_8 );
utf8 = (char *) malloc( outLen/sizeof(UniChar) );
if( utf8 == NULL )
return strdup(src);
err = NLS_ConvertBuffer( ldaptool_charset,
NLS_ENCODING_UTF_8,
(byte*)src,
strlen(src) * sizeof(char),
(byte*)utf8,
outLen,
&resultLen );
NLS_EncTerminate();
#else
utf8 = _convertor(src, FALSE);
if( utf8 == NULL )
utf8 = strdup(src);
#endif
return utf8;
}

View File

@@ -0,0 +1,181 @@
# LDIF examples, taken from the specification which was found at:
# http://www.ietf.org/internet-drafts/draft-good-ldap-ldif-03.txt
# Example 1: An simple LDAP file with two entries
version: 1
dn: cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
cn: Barbara Jensen
cn: Barbara J Jensen
cn: Babs Jensen
sn: Jensen
uid: bjensen
telephonenumber: +1 408 555 1212
description: A big sailing fan.
dn: cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
cn: Bjorn Jensen
sn: Jensen
telephonenumber: +1 408 555 1212
# Example 2: A file containing an entry with a folded attribute value
version: 1
dn:cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com
objectclass:top
objectclass:person
objectclass:organizationalPerson
cn:Barbara Jensen
cn:Barbara J Jensen
cn:Babs Jensen
sn:Jensen
uid:bjensen
telephonenumber:+1 408 555 1212
description:Babs is a big sailing fan, and travels extensively in search of
perfect sailing conditions.
title:Product Manager, Rod and Reel Division
# Example 3: A file containing a base-64-encoded value
version: 1
dn: cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
cn: Gern Jensen
cn: Gern O Jensen
sn: Jensen
uid: gernj
telephonenumber: +1 408 555 1212
description:: V2hhdCBhIGNhcmVmdWwgcmVhZGVyIHlvdSBhcmUhICBUaGlzIHZhbHVlIGlzIGJ
hc2UtNjQtZW5jb2RlZCBiZWNhdXNlIGl0IGhhcyBhIGNvbnRyb2wgY2hhcmFjdGVyIGluIGl0ICh
hIENSKS4NICBCeSB0aGUgd2F5LCB5b3Ugc2hvdWxkIHJlYWxseSBnZXQgb3V0IG1vcmUu
# Example 4: A file containing an entries with UTF-8-encoded attribute
# values, including language tags. Comments indicate the contents
# of UTF-8-encoded attributes and distinguished names.
version: 1
dn:: b3U95Za25qWt6YOoLG89QWlyaXVz
# dn:: ou=<JapaneseOU>,o=Airius
objectclass: top
objectclass: organizationalUnit
ou:: 5Za25qWt6YOo
# ou:: <JapaneseOU>
ou;lang-ja:: 5Za25qWt6YOo
# ou;lang-ja:: <JapaneseOU>
ou;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2
# ou;lang-ja:: <JapaneseOU_in_phonetic_representation>
ou;lang-en: Sales
description: Japanese office
dn:: dWlkPXJvZ2FzYXdhcmEsb3U95Za25qWt6YOoLG89QWlyaXVz
# dn:: uid=<uid>,ou=<JapaneseOU>,o=Airius
userpassword: {SHA}O3HSv1MusyL4kTjP+HKI5uxuNoM=
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
uid: rogasawara
mail: rogasawara@airius.co.jp
givenname;lang-ja:: 44Ot44OJ44OL44O8
# givenname;lang-ja:: <JapaneseGivenname>
sn;lang-ja:: 5bCP56yg5Y6f
# sn;lang-ja:: <JapaneseSn>
cn;lang-ja:: 5bCP56yg5Y6fIOODreODieODi+ODvA==
# cn;lang-ja:: <JapaneseCn>
title;lang-ja:: 5Za25qWt6YOoIOmDqOmVtw==
# title;lang-ja:: <JapaneseTitle>
preferredlanguage: ja
givenname:: 44Ot44OJ44OL44O8
# givenname:: <JapaneseGivenname>
sn:: 5bCP56yg5Y6f
# sn:: <JapaneseSn>
cn:: 5bCP56yg5Y6fIOODreODieODi+ODvA==
# cn:: <JapaneseCn>
title:: 5Za25qWt6YOoIOmDqOmVtw==
# title:: <JapaneseTitle>
givenname;lang-ja;phonetic:: 44KN44Gp44Gr44O8
# givenname;lang-ja;phonetic:: <JapaneseGivenname_in_phonetic_representation_kana>
sn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJ
# sn;lang-ja;phonetic:: <JapaneseSn_in_phonetic_representation_kana>
cn;lang-ja;phonetic:: 44GK44GM44GV44KP44KJIOOCjeOBqeOBq+ODvA==
# cn;lang-ja;phonetic:: <JapaneseCn_in_phonetic_representation_kana>
title;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2IOOBtuOBoeOCh+OBhg==
# title;lang-ja;phonetic:: <JapaneseTitle_in_phonetic_representation_kana>
givenname;lang-en: Rodney
sn;lang-en: Ogasawara
cn;lang-en: Rodney Ogasawara
title;lang-en: Sales, Director
# Example 5: A file containing a reference to an external file
version: 1
dn: cn=Horatio Jensen, ou=Product Testing, dc=airius, dc=com
objectclass: top
objectclass: person
objectclass: organizationalPerson
cn: Horatio Jensen
cn: Horatio N Jensen
sn: Jensen
uid: hjensen
telephonenumber: +1 408 555 1212
# XXXmcs: In the spec, the following line reads:
# jpegphoto:< file:///usr/local/directory/photos/hjensen.jpg
# I changed the file URL to point to a more generic directory.
jpegphoto:< file:///tmp/hjensen.jpg
# Example 6: A file containing a series of change records and comments
version: 1
# Add a new entry
dn: cn=Fiona Jensen, ou=Marketing, dc=airius, dc=com
changetype: add
objectclass: top
objectclass: person
objectclass: organizationalPerson
cn: Fiona Jensen
sn: Jensen
uid: fiona
telephonenumber: +1 408 555 1212
# XXXmcs: In the spec, the following line reads:
# jpegphoto:< file:///usr/local/directory/photos/fiona.jpg
# I changed the file URL to point to a more generic directory.
jpegphoto:< file:///tmp/fiona.jpg
# Delete an existing entry
dn: cn=Robert Jensen, ou=Marketing, dc=airius, dc=com
changetype: delete
# Modify an entry's relative distinguished name
dn: cn=Paul Jensen, ou=Product Development, dc=airius, dc=com
changetype: modrdn
newrdn: cn=Paula Jensen
deleteoldrdn: 1
# Rename an entry and move all of its children to a new location in
# the directory tree (only implemented by LDAPv3 servers).
dn: ou=PD Accountants, ou=Product Development, dc=airius, dc=com
changetype: modrdn
newrdn: ou=Product Development Accountants
deleteoldrdn: 0
newsuperior: ou=Accounting, dc=airius, dc=com
# Modify an entry: add an additional value to the postaladdress attribute,
# completely delete the description attribute, replace the telephonenumber
# attribute with two values, and delete a specific value from the
# facsimiletelephonenumber attribute
dn: cn=Paula Jensen, ou=Product Development, dc=airius, dc=com
changetype: modify
add: postaladdress
postaladdress: 123 Anystreet $ Sunnyvale, CA $ 94086
-
delete: description
-
replace: telephonenumber
telephonenumber: +1 408 555 1234
telephonenumber: +1 408 555 5678
-
delete: facsimiletelephonenumber
facsimiletelephonenumber: +1 408 555 9876
-

View File

@@ -0,0 +1,280 @@
/*
* LDAP tools fileurl.c -- functions for handling file URLs.
* Used by ldapmodify.
*/
#include "ldaptool.h"
#include "fileurl.h"
#include <ctype.h> /* for isalpha() */
static int str_starts_with( char *s, char *prefix );
static void hex_unescape( char *s );
static int unhex( char c );
static void strcpy_escaped_and_convert( char *s1, char *s2 );
/*
* Convert a file URL to a local path.
*
* If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *localpathp is
* set point to an allocated string. If not, an different LDAPTOOL_FILEURL_
* error code is returned.
*
* See RFCs 1738 and 2396 for a specification for file URLs... but
* Netscape Navigator seems to be a bit more lenient in what it will
* accept, especially on Windows).
*
* This function parses file URLs of these three forms:
*
* file:///path
* file:/path
* file://localhost/path
* file://host/path (rejected with a ...NONLOCAL error)
*
* On Windows, we convert leading drive letters of the form C| to C:
* and if a drive letter is present we strip off the slash that precedes
* path. Otherwise, the leading slash is returned.
*
*/
int
ldaptool_fileurl2path( char *fileurl, char **localpathp )
{
char *path;
/*
* Make sure this is a file URL we can handle.
*/
if ( !str_starts_with( fileurl, "file:" )) {
return( LDAPTOOL_FILEURL_NOTAFILEURL );
}
path = fileurl + 5; /* skip past "file:" scheme prefix */
if ( *path != '/' ) {
return( LDAPTOOL_FILEURL_MISSINGPATH );
}
++path; /* skip past '/' at end of "file:/" */
if ( *path == '/' ) {
++path; /* remainder is now host/path or /path */
if ( *path != '/' ) {
/*
* Make sure it is for the local host.
*/
if ( str_starts_with( path, "localhost/" )) {
path += 9;
} else {
return( LDAPTOOL_FILEURL_NONLOCAL );
}
}
} else { /* URL is of the form file:/path */
--path;
}
/*
* The remainder is now of the form /path. On Windows, skip past the
* leading slash if a drive letter is present.
*/
#ifdef _WINDOWS
if ( isalpha( path[1] ) && ( path[2] == '|' || path[2] == ':' )) {
++path;
}
#endif /* _WINDOWS */
/*
* Duplicate the path so we can safely alter it.
* Unescape any %HH sequences.
*/
if (( path = strdup( path )) == NULL ) {
return( LDAPTOOL_FILEURL_NOMEMORY );
}
hex_unescape( path );
#ifdef _WINDOWS
/*
* Convert forward slashes to backslashes for Windows. Also,
* if we see a drive letter / vertical bar combination (e.g., c|)
* at the beginning of the path, replace the '|' with a ':'.
*/
{
char *p;
for ( p = path; *p != '\0'; ++p ) {
if ( *p == '/' ) {
*p = '\\';
}
}
}
if ( isalpha( path[0] ) && path[1] == '|' ) {
path[1] = ':';
}
#endif /* _WINDOWS */
*localpathp = path;
return( LDAPTOOL_FILEURL_SUCCESS );
}
/*
* Convert a local path to a file URL.
*
* If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *urlp is
* set point to an allocated string. If not, an different LDAPTOOL_FILEURL_
* error code is returned. At present, the only possible error is
* LDAPTOOL_FILEURL_NOMEMORY.
*
* This function produces file URLs of the form file:path.
*
* On Windows, we convert leading drive letters to C|.
*
*/
int
ldaptool_path2fileurl( char *path, char **urlp )
{
char *p, *url, *prefix ="file:";
if ( NULL == path ) {
path = "/";
}
/*
* Allocate space for the URL, taking into account that path may
* expand during the hex escaping process.
*/
if (( url = malloc( strlen( prefix ) + 3 * strlen( path ) + 1 )) == NULL ) {
return( LDAPTOOL_FILEURL_NOMEMORY );
}
strcpy( url, prefix );
p = url + strlen( prefix );
#ifdef _WINDOWS
/*
* On Windows, convert leading drive letters (e.g., C:) to the correct URL
* syntax (e.g., C|).
*/
if ( isalpha( path[0] ) && path[1] == ':' ) {
*p++ = path[0];
*p++ = '|';
path += 2;
*p = '\0';
}
#endif /* _WINDOWS */
/*
* Append the path, encoding any URL-special characters using the %HH
* convention.
* On Windows, convert backwards slashes in the path to forward ones.
*/
strcpy_escaped_and_convert( p, path );
*urlp = url;
return( LDAPTOOL_FILEURL_SUCCESS );
}
/*
* Return a non-zero value if the string s begins with prefix and zero if not.
*/
static int
str_starts_with( char *s, char *prefix )
{
size_t prefix_len;
if ( s == NULL || prefix == NULL ) {
return( 0 );
}
prefix_len = strlen( prefix );
if ( strlen( s ) < prefix_len ) {
return( 0 );
}
return( strncmp( s, prefix, prefix_len ) == 0 );
}
/*
* Remove URL hex escapes from s... done in place. The basic concept for
* this routine is borrowed from the WWW library HTUnEscape() routine.
*
* A similar function called nsldapi_hex_unescape can be found in
* ../../libraries/libldap/unescape.c
*/
static void
hex_unescape( char *s )
{
char *p;
for ( p = s; *s != '\0'; ++s ) {
if ( *s == '%' ) {
if ( *++s != '\0' ) {
*p = unhex( *s ) << 4;
}
if ( *++s != '\0' ) {
*p++ += unhex( *s );
}
} else {
*p++ = *s;
}
}
*p = '\0';
}
/*
* Return the integer equivalent of one hex digit (in c).
*
* A similar function can be found in ../../libraries/libldap/unescape.c
*/
static int
unhex( char c )
{
return( c >= '0' && c <= '9' ? c - '0'
: c >= 'A' && c <= 'F' ? c - 'A' + 10
: c - 'a' + 10 );
}
#define HREF_CHAR_ACCEPTABLE( c ) (( c >= '-' && c <= '9' ) || \
( c >= '@' && c <= 'Z' ) || \
( c == '_' ) || \
( c >= 'a' && c <= 'z' ))
/*
* Like strcat(), except if any URL-special characters are found in s2
* they are escaped using the %HH convention and backslash characters are
* converted to forward slashes on Windows.
*
* Maximum space needed in s1 is 3 * strlen( s2 ) + 1.
*
* A similar function that does not convert the slashes called
* strcat_escaped() can be found in ../../libraries/libldap/tmplout.c
*/
static void
strcpy_escaped_and_convert( char *s1, char *s2 )
{
char *p, *q;
char *hexdig = "0123456789ABCDEF";
p = s1 + strlen( s1 );
for ( q = s2; *q != '\0'; ++q ) {
#ifdef _WINDOWS
if ( *q == '\\' ) {
*p++ = '/';
} else
#endif /* _WINDOWS */
if ( HREF_CHAR_ACCEPTABLE( *q )) {
*p++ = *q;
} else {
*p++ = '%';
*p++ = hexdig[ 0x0F & ((*(unsigned char*)q) >> 4) ];
*p++ = hexdig[ 0x0F & *q ];
}
}
*p = '\0';
}

View File

@@ -0,0 +1,35 @@
/*
* LDAP tools fileurl.h -- defines for file URL functions.
* Used by ldapmodify.
*/
/*
* ldaptool_fileurl2path() convert a file URL to a local path.
*
* If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *localpathp is
* set point to an allocated string. If not, an differnet LDAPTOOL_FILEURL_
* error code is returned.
*/
int ldaptool_fileurl2path( char *fileurl, char **localpathp );
/*
* Convert a local path to a file URL.
*
* If successful, LDAPTOOL_FILEURL_SUCCESS is returned and *urlp is
* set point to an allocated string. If not, an different LDAPTOOL_FILEURL_
* error code is returned. At present, the only possible error is
* LDAPTOOL_FILEURL_NOMEMORY.
*
*/
int ldaptool_path2fileurl( char *path, char **urlp );
/*
* Possible return codes for ldaptool_fileurl2path and ldaptool_path2fileurl.
*/
#define LDAPTOOL_FILEURL_SUCCESS 0
#define LDAPTOOL_FILEURL_NOTAFILEURL 1
#define LDAPTOOL_FILEURL_MISSINGPATH 2
#define LDAPTOOL_FILEURL_NONLOCAL 3
#define LDAPTOOL_FILEURL_NOMEMORY 4

View File

@@ -0,0 +1,596 @@
/* tool to compare the contents of two LDAP directory subtrees */
#include "ldaptool.h"
typedef struct attr {
char *name;
char **vals;
struct attr *next;
} ATTR; /* used for comparing two entries */
static void options_callback( int option, char *optarg );
static int docompare( LDAP *ld1, LDAP *ld2, char *base );
static int cmp2(LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly );
static void notfound(char *base, int dbaseno);
ATTR* get_attrs( LDAP *ld, LDAPMessage *e );
char* cmp_attrs( ATTR *a1, ATTR *a2 );
static void attr_free(ATTR *at);
#if 0 /* these functions are not used */
static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly );
static void print_dn( LDAP *ld, LDAPMessage *entry );
static int write_ldif_value( char *type, char *value, unsigned long vallen );
#endif /* 0 */
static void
usage( void )
{
fprintf( stderr,
"usage: %s -b basedn [options] [attributes...]\nwhere:\n",
ldaptool_progname );
fprintf( stderr, " basedn\tbase dn for search\n" );
fprintf( stderr, "\t\t(if the environment variable LDAP_BASEDN is set,\n" );
fprintf( stderr, "\t\tthen the -b flag is not required)\n" );
fprintf( stderr, "options:\n" );
ldaptool_common_usage( 1 );
exit( LDAP_PARAM_ERROR );
}
static char *base = NULL;
static int allow_binary, vals2tmp, ldif, scope, deref;
static int attrsonly, timelimit, sizelimit;
#if 0 /* these statics are referenced only by unused functions */
static char *sep = LDAPTOOL_DEFSEP;
static char **sortattr = NULL;
static int *skipsortattr = NULL;
static int includeufn;
#endif /* 0 */
int
main( int argc, char **argv )
{
int rc, optind;
LDAP *ld1, *ld2;
#ifdef HPUX11
#ifndef __LP64__
_main( argc, argv);
#endif /* __LP64_ */
#endif /* HPUX11 */
deref = allow_binary = vals2tmp = attrsonly = 0;
ldif = 1;
sizelimit = timelimit = 0;
scope = LDAP_SCOPE_SUBTREE;
optind = ldaptool_process_args( argc, argv, "Bb:l:s:z:", 0,
options_callback );
if ( base == NULL ) {
if (( base = getenv( "LDAP_BASEDN" )) == NULL ) {
usage();
}
}
ld1 = ldaptool_ldap_init( 0 );
ldap_set_option( ld1, LDAP_OPT_DEREF, &deref );
ldap_set_option( ld1, LDAP_OPT_TIMELIMIT, &timelimit );
ldap_set_option( ld1, LDAP_OPT_SIZELIMIT, &sizelimit );
ldaptool_bind( ld1 );
ld2 = ldaptool_ldap_init( 1 );
ldap_set_option( ld2, LDAP_OPT_DEREF, &deref );
ldap_set_option( ld2, LDAP_OPT_TIMELIMIT, &timelimit );
ldap_set_option( ld2, LDAP_OPT_SIZELIMIT, &sizelimit );
ldaptool_bind( ld2 );
if ( ldaptool_verbose ) {
printf( "Connections to servers established. Beginning comparison.\n" );
}
rc = docompare( ld1, ld2, base );
ldaptool_cleanup( ld1 );
ldaptool_cleanup( ld2 );
if ( ldaptool_verbose ) {
if ( 0 == rc ) {
printf( "compare completed: no differences found\n" );
} else {
printf( "compare completed: ****differences were found****\n" );
}
}
return( rc );
}
static void
options_callback( int option, char *optarg )
{
switch( option ) {
case 'B': /* allow binary values to be printed, even if -o used */
++allow_binary;
break;
case 's': /* search scope */
if ( strncasecmp( optarg, "base", 4 ) == 0 ) {
scope = LDAP_SCOPE_BASE;
} else if ( strncasecmp( optarg, "one", 3 ) == 0 ) {
scope = LDAP_SCOPE_ONELEVEL;
} else if ( strncasecmp( optarg, "sub", 3 ) == 0 ) {
scope = LDAP_SCOPE_SUBTREE;
} else {
fprintf( stderr, "scope should be base, one, or sub\n" );
usage();
}
break;
case 'b': /* searchbase */
base = strdup( optarg );
break;
case 'l': /* time limit */
timelimit = atoi( optarg );
break;
case 'z': /* size limit */
sizelimit = atoi( optarg );
break;
default:
usage();
break;
}
}
/*
* Returns an LDAP error code.
*/
static int
docompare( LDAP *ld1, LDAP *ld2, char *base )
{
int rc, msgid;
LDAPMessage *res, *e;
LDAPControl *ctrls[2], **serverctrls;
if ( ldaptool_verbose ) {
printf( "Base: %s\n\n", base );
}
if ( ldaptool_not ) {
return( LDAP_SUCCESS );
}
if (( ctrls[0] = ldaptool_create_manage_dsait_control()) != NULL ) {
ctrls[1] = NULL;
serverctrls = ctrls;
} else {
serverctrls = NULL;
}
if ( ldap_search_ext( ld1, base, LDAP_SCOPE_BASE, "objectClass=*", NULL,
0, serverctrls, NULL, NULL, -1, &msgid ) != LDAP_SUCCESS ) {
return( ldaptool_print_lderror( ld1, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
/* XXXmcs: this code should be modified to display referrals and references */
while ( (rc = ldap_result( ld1, LDAP_RES_ANY, 0, NULL, &res )) ==
LDAP_RES_SEARCH_ENTRY ) {
e = ldap_first_entry( ld1, res );
rc = cmp2( ld1, ld2, e , 0);
ldap_msgfree( res );
}
if ( rc == -1 ) {
return( ldaptool_print_lderror( ld1, "ldap_result",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) {
ldaptool_print_lderror( ld1, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP );
}
ldap_msgfree( res );
if ( ldap_search_ext( ld2, base, LDAP_SCOPE_BASE, "objectClass=*", NULL,
0, serverctrls, NULL, NULL, -1, &msgid ) == -1 ) {
return( ldaptool_print_lderror( ld2, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
/* XXXmcs: this code should be modified to display referrals and references */
while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) ==
LDAP_RES_SEARCH_ENTRY ) {
e = ldap_first_entry( ld2, res );
rc = cmp2( ld2, ld1, e , 1);
ldap_msgfree( res );
}
if ( rc == -1 ) {
return( ldaptool_print_lderror( ld2, "ldap_result",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) {
ldaptool_print_lderror( ld1, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP );
}
ldap_msgfree( res );
return( rc );
}
/*
* Returns an LDAP error code.
*/
static int
cmp2( LDAP *ld1, LDAP *ld2, LDAPMessage *e1, int findonly)
{
LDAPMessage *e2, *res;
char *dn, *attrcmp;
int found=0, rc, msgid;
ATTR *a1, *a2;
dn = ldap_get_dn( ld1, e1 );
if ( ldaptool_verbose ) {
if ( findonly ) {
printf( "Checking that %s exists on both servers\n", dn );
} else {
printf("Comparing entry %s on both servers\n", dn );
}
}
if ( ldap_search( ld2, dn, LDAP_SCOPE_BASE, "objectClass=*", NULL, 0 ) == -1 ) {
return( ldaptool_print_lderror( ld2, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
/* XXXmcs: this code should be modified to display referrals and references */
while ( (rc = ldap_result( ld2, LDAP_RES_ANY, 0, NULL, &res )) ==
LDAP_RES_SEARCH_ENTRY ) {
e2 = ldap_first_entry( ld1, res );
found = 1;
if ( !findonly ) {
a1 = get_attrs( ld1, e1 );
a2 = get_attrs( ld2, e2 );
attrcmp = cmp_attrs( a1, a2 );
if ( strcmp( attrcmp, "") != 0 ) {
printf("\n%s%s\n", dn, attrcmp);
}
}
ldap_msgfree( res );
}
if ( !found ) {
notfound( dn, findonly );
}
if ( rc == -1 ) {
return( ldaptool_print_lderror( ld2, "ldap_result",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
ldap_msgfree( res );
if (( msgid = ldap_search( ld1, dn, LDAP_SCOPE_ONELEVEL, "objectClass=*" , NULL, 0 )) == -1 ) {
return( ldaptool_print_lderror( ld1, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
/* XXXmcs: this code should be modified to display referrals and references */
while ( (rc = ldap_result( ld1, msgid, 0, NULL, &res )) ==
LDAP_RES_SEARCH_ENTRY ) {
e2 = ldap_first_entry( ld1, res );
rc = cmp2( ld1, ld2, e2, findonly );
ldap_msgfree( res );
}
if ( rc == -1 ) {
return( ldaptool_print_lderror( ld1, "ldap_result",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
if (( rc = ldap_result2error( ld1, res, 0 )) != LDAP_SUCCESS ) {
ldaptool_print_lderror( ld1, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP );
}
ldap_msgfree( res );
ldap_memfree( dn );
return(rc);
}
ATTR*
get_attrs( LDAP *ld, LDAPMessage *e )
{
char *a;
ATTR *head, *tail, *tmp;
BerElement *ber;
head=tail=tmp=NULL;
for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
a = ldap_next_attribute( ld, e, ber ) ) {
tmp = (ATTR*)malloc(sizeof(ATTR));
if(head == NULL)
head = tail = tmp;
else {
tail->next = tmp;
tail = tmp;
}
tmp->name = a;
tmp->vals = ldap_get_values( ld, e, a );
tmp->next = NULL;
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
/* used for debugging
tmp=head;
while(tmp!= NULL) {
printf("\n%s :", tmp->name);
for(i=0; tmp->vals[i] != NULL; i++)
printf("\n\t%d %s", i, tmp->vals[i]);
tmp = tmp->next;
}
*/
return(head);
}
char*
cmp_attrs( ATTR *a1, ATTR *a2 )
{
static char result[5000];
char res[1000], partial[1000], *name = "";
ATTR *head1, *head2, *tmp, *prev, *start;
int i, j, found;
head1 = a1;
head2 = a2;
tmp = a2;
prev = NULL;
strcpy(result, "");
while(head1 != NULL) {
name = head1->name;
if(head2 == NULL) {
while(head1 != NULL) {
sprintf(partial, "\ndifferent: %s(*)", head1->name);
strcat(result, partial);
for(i=0; head1->vals[i] != NULL; i++) {
sprintf(partial,"\n\t1: %s", head1->vals[i]);
strcat(result, partial);
}
tmp = head1;
head1 = head1->next;
attr_free(tmp);
}
break;
}
name = head1->name;
start = tmp;
while(tmp != NULL) {
if(!strcmp(name, tmp->name)) { /* attr found */
strcpy(res, "");
for(i=0; (head1->vals[i]) != NULL; i++) {
found = 0;
for(j=0; (tmp->vals[j]) != NULL; j++)
if(!strcmp(head1->vals[i], tmp->vals[j])) {
found = 1;
tmp->vals[j][0] = 7;
break;
}
if(!found) {
sprintf(partial, "\n\t1: %s", head1->vals[i]);
strcat(res, partial);
}
}
for(j=0; tmp->vals[j] != NULL; j++)
if(tmp->vals[j][0] != 7){
sprintf(partial, "\n\t2: %s", tmp->vals[j]);
strcat(res, partial);
}
if(strcmp(res, "")) {
sprintf(partial, "\ndifferent: %s%s", name, res);
strcat(result, partial);
}
if(prev == NULL) { /* tmp = head2 */
head2 = head2->next;
attr_free(tmp);
tmp = head2;
}
else {
prev->next = tmp->next;
attr_free(tmp);
tmp = prev->next;
if(tmp == NULL) {
tmp = head2;
prev = NULL;
}
}
break;
}
else { /* attr not found */
if(prev == NULL)
prev = head2;
else
prev = tmp;
tmp = tmp->next;
if(tmp == NULL) { /* end of list */
tmp = head2;
prev = NULL;
}
if(tmp == start) { /* attr !exist in 2 */
sprintf(partial, "\ndifferent: %s(*)", name);
strcat(result, partial);
for(i=0; head1->vals[i] != NULL; i++) {
sprintf(partial, "\n\t1: %s", head1->vals[i]);
strcat(result, partial);
}
break;
}
}
}
start = head1;
head1 = head1->next;
attr_free(start);
}
while(head2 != NULL) {
sprintf(partial, "\ndifferent: %s(*)", head2->name);
strcat(result, partial);
for(i=0; head2->vals[i] != NULL; i++) {
sprintf(partial, "\n\t2: %s", head2->vals[i]);
strcat(result, partial);
}
tmp = head2;
head2 = head2->next;
attr_free(tmp);
}
return(result);
}
static void
attr_free(ATTR *at)
{
ldap_memfree(at->name);
ldap_value_free(at->vals);
free(at);
}
static void
notfound(char *base, int dbaseno)
{
printf("%donly: %s\n", dbaseno+1, base);
}
#if 0 /* these function is not used */
/* used for debugging */
static void
print_dn( LDAP *ld, LDAPMessage *entry )
{
char *dn, *ufn;
dn = ldap_get_dn( ld, entry );
if ( ldif ) {
write_ldif_value( "dn", dn, strlen( dn ));
} else {
printf( "%s\n", dn );
}
if ( includeufn ) {
ufn = ldap_dn2ufn( dn );
if ( ldif ) {
write_ldif_value( "ufn", ufn, strlen( ufn ));
} else {
printf( "%s\n", ufn );
}
free( ufn );
}
ldap_memfree( dn );
}
static void
print_entry( ld, entry, attrsonly )
LDAP *ld;
LDAPMessage *entry;
int attrsonly;
{
char *a, *dn, *ufn, tmpfname[ 256 ];
int i, notascii;
BerElement *ber;
struct berval **bvals;
FILE *tmpfp;
#if defined( XP_WIN32 )
char mode[20] = "w+b";
#else
char mode[20] = "w";
#endif
dn = ldap_get_dn( ld, entry );
if ( ldif ) {
write_ldif_value( "dn", dn, strlen( dn ));
} else {
printf( "%s\n", dn );
}
if ( includeufn ) {
ufn = ldap_dn2ufn( dn );
if ( ldif ) {
write_ldif_value( "ufn", ufn, strlen( ufn ));
} else {
printf( "%s\n", ufn );
}
free( ufn );
}
ldap_memfree( dn );
for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL;
a = ldap_next_attribute( ld, entry, ber ) ) {
if ( ldap_charray_inlist(sortattr, a) && /* in the list*/
skipsortattr[ldap_charray_position(sortattr, a)] ) {/* and skip it*/
continue; /* so skip it! */
}
if ( attrsonly ) {
if ( ldif ) {
write_ldif_value( a, "", 0 );
} else {
printf( "%s\n", a );
}
} else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) {
for ( i = 0; bvals[i] != NULL; i++ ) {
if ( vals2tmp ) {
sprintf( tmpfname, "%s/ldapcmp-%s-XXXXXX",
ldaptool_get_tmp_dir(), a );
tmpfp = NULL;
if ( mktemp( tmpfname ) == NULL ) {
perror( tmpfname );
} else if (( tmpfp = fopen( tmpfname, mode)) == NULL ) {
perror( tmpfname );
} else if ( fwrite( bvals[ i ]->bv_val,
bvals[ i ]->bv_len, 1, tmpfp ) == 0 ) {
perror( tmpfname );
} else if ( ldif ) {
write_ldif_value( a, tmpfname, strlen( tmpfname ));
} else {
printf( "%s%s%s\n", a, sep, tmpfname );
}
if ( tmpfp != NULL ) {
fclose( tmpfp );
}
} else {
notascii = 0;
if ( !ldif && !allow_binary ) {
unsigned long j;
for ( j = 0; j < bvals[ i ]->bv_len; ++j ) {
if ( !isascii( bvals[ i ]->bv_val[ j ] )) {
notascii = 1;
break;
}
}
}
if ( ldif ) {
write_ldif_value( a, bvals[ i ]->bv_val,
bvals[ i ]->bv_len );
} else {
printf( "%s%s%s\n", a, sep,
notascii ? "NOT ASCII" : bvals[ i ]->bv_val );
}
}
}
ber_bvecfree( bvals );
}
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
}
static int
write_ldif_value( char *type, char *value, unsigned long vallen )
{
char *ldif;
if (( ldif = ldif_type_and_value( type, value, (int)vallen )) == NULL ) {
return( -1 );
}
fputs( ldif, stdout );
free( ldif );
return( 0 );
}
#endif /* 0 */

View File

@@ -0,0 +1,115 @@
/* ldapdelete.c - simple program to delete an entry using LDAP */
#include "ldaptool.h"
static int contoper;
static LDAP *ld;
static int dodelete( LDAP *ld, char *dn, LDAPControl **serverctrls );
static void options_callback( int option, char *optarg );
static void
usage( void )
{
fprintf( stderr, "usage: %s [options] [dn...]\n", ldaptool_progname );
fprintf( stderr, "options:\n" );
ldaptool_common_usage( 0 );
fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" );
fprintf( stderr, " -f file\tread DNs to delete from file\n" );
exit( LDAP_PARAM_ERROR );
}
int
main( int argc, char **argv )
{
char buf[ 4096 ];
int rc, deref, optind;
LDAPControl *ldctrl;
#ifdef HPUX11
#ifndef __LP64__
_main( argc, argv);
#endif /* __LP64_ */
#endif /* HPUX11 */
contoper = 0;
optind = ldaptool_process_args( argc, argv, "c", 0, options_callback );
if ( ldaptool_fp == NULL && optind >= argc ) {
ldaptool_fp = stdin;
}
ld = ldaptool_ldap_init( 0 );
deref = LDAP_DEREF_NEVER; /* prudent, but probably unnecessary */
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
ldaptool_bind( ld );
if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) {
ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls);
}
if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) {
ldaptool_add_control_to_array( ldctrl, ldaptool_request_ctrls);
}
if ( ldaptool_fp == NULL ) {
for ( ; optind < argc; ++optind ) {
char *conv;
conv = ldaptool_local2UTF8( argv[ optind ] );
rc = dodelete( ld, conv, ldaptool_request_ctrls );
if( conv != NULL )
free( conv );
}
} else {
rc = 0;
while ((rc == 0 || contoper) &&
fgets(buf, sizeof(buf), ldaptool_fp) != NULL) {
buf[ strlen( buf ) - 1 ] = '\0'; /* remove trailing newline */
if ( *buf != '\0' ) {
rc = dodelete( ld, buf, ldaptool_request_ctrls );
}
}
}
ldaptool_reset_control_array( ldaptool_request_ctrls );
ldaptool_cleanup( ld );
return( rc );
}
static void
options_callback( int option, char *optarg )
{
switch( option ) {
case 'c': /* continuous operation mode */
++contoper;
break;
default:
usage();
}
}
static int
dodelete( LDAP *ld, char *dn, LDAPControl **serverctrls )
{
int rc;
if ( ldaptool_verbose ) {
printf( "%sdeleting entry %s\n", ldaptool_not ? "!" : "", dn );
}
if ( ldaptool_not ) {
rc = LDAP_SUCCESS;
} else if (( rc = ldaptool_delete_ext_s( ld, dn, serverctrls, NULL,
"ldap_delete" )) == LDAP_SUCCESS && ldaptool_verbose ) {
printf( "entry removed\n" );
}
return( rc );
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,146 @@
/* ldapmodrdn.c - generic program to modify an entry's RDN using LDAP */
#include "ldaptool.h"
static int domodrdn( LDAP *ld, char *dn, char *rdn, int remove,
LDAPControl **serverctrls);
static void options_callback( int option, char *optarg );
static int contoper, remove_oldrdn;
static LDAP *ld;
static void
usage( void )
{
fprintf( stderr, "usage: %s [options] [dn rdn]\n", ldaptool_progname );
fprintf( stderr, "options:\n" );
ldaptool_common_usage( 0 );
fprintf( stderr, " -c\t\tcontinuous mode (do not stop on errors)\n" );
fprintf( stderr, " -r\t\tremove old RDN\n" );
fprintf( stderr, " -f file\tread changes from file\n" );
exit( LDAP_PARAM_ERROR );
}
main( argc, argv )
int argc;
char **argv;
{
char *entrydn, *rdn, buf[ 4096 ];
int rc, havedn, deref, optind;
LDAPControl *ctrls[2], **serverctrls;
contoper = remove_oldrdn = 0;
optind = ldaptool_process_args( argc, argv, "cr", 0, options_callback );
if ( ldaptool_fp == NULL ) {
ldaptool_fp = stdin;
}
havedn = 0;
if (argc - optind == 2) {
if (( rdn = strdup( argv[argc - 1] )) == NULL ) {
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
if (( entrydn = strdup( argv[argc - 2] )) == NULL ) {
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
++havedn;
} else if ( argc - optind != 0 ) {
fprintf( stderr, "%s: invalid number of arguments, only two allowed\n",
ldaptool_progname );
usage();
}
ld = ldaptool_ldap_init( 0 );
if ( !ldaptool_not ) {
deref = LDAP_DEREF_NEVER; /* this seems prudent */
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
}
ldaptool_bind( ld );
if (( ctrls[0] = ldaptool_create_manage_dsait_control()) != NULL ) {
ctrls[1] = NULL;
serverctrls = ctrls;
} else {
serverctrls = NULL;
}
rc = 0;
if (havedn) {
rc = domodrdn(ld, entrydn, rdn, remove_oldrdn, serverctrls);
} else while ((rc == 0 || contoper) &&
fgets(buf, sizeof(buf), ldaptool_fp) != NULL) {
if ( *buf != '\0' && *buf != '\n' ) { /* skip blank lines */
buf[ strlen( buf ) - 1 ] = '\0'; /* remove nl */
if ( havedn ) { /* have DN, get RDN */
if (( rdn = strdup( buf )) == NULL ) {
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
rc = domodrdn(ld, entrydn, rdn, remove_oldrdn, serverctrls);
havedn = 0;
} else if ( !havedn ) { /* don't have DN yet */
if (( entrydn = strdup( buf )) == NULL ) {
perror( "strdup" );
exit( LDAP_NO_MEMORY );
}
++havedn;
}
}
}
ldaptool_cleanup( ld );
exit( rc );
}
static void
options_callback( int option, char *optarg )
{
switch( option ) {
case 'c': /* continuous operation mode */
++contoper;
break;
case 'r': /* remove old RDN */
++remove_oldrdn;
break;
default:
usage();
}
}
static int
domodrdn( LDAP *ld, char *dn, char *rdn, int remove_oldrdn,
LDAPControl **serverctrls )
{
int i;
if ( ldaptool_verbose ) {
printf( "modrdn %s:\n\t%s\n", dn, rdn );
if (remove_oldrdn)
printf("removing old RDN\n");
else
printf("keeping old RDN\n");
}
if ( !ldaptool_not ) {
if (( i = ldaptool_rename_s( ld, dn, rdn, NULL, remove_oldrdn,
serverctrls, NULL, "ldap_rename" )) == LDAP_SUCCESS
&& ldaptool_verbose ) {
printf( "modrdn complete\n" );
}
} else {
i = LDAP_SUCCESS;
}
return( i );
}

View File

@@ -0,0 +1,935 @@
/* ldapsearch.c - generic program to search LDAP */
#include "ldaptool.h"
#include "fileurl.h"
#define VLV_PARAM_SEP ':'
static void usage( void );
static int dosearch( LDAP *ld, char *base, int scope, char **attrs,
int attrsonly, char *filtpatt, char *value);
static int write_ldif_value( char *type, char *value, unsigned long vallen,
unsigned long ldifoptions );
static void print_entry( LDAP *ld, LDAPMessage *entry, int attrsonly );
static void options_callback( int option, char *optarg );
static void parse_and_display_reference( LDAP *ld, LDAPMessage *ref );
static char *sortresult2string(unsigned long result);
static char *msgtype2str( int msgtype );
static void
usage( void )
{
fprintf( stderr, "usage: %s -b basedn [options] filter [attributes...]\n", ldaptool_progname );
fprintf( stderr, " %s -b basedn [options] -f file [attributes...]\nwhere:\n", ldaptool_progname );
fprintf( stderr, " basedn\tbase dn for search\n" );
fprintf( stderr, "\t\t(if the environment variable LDAP_BASEDN is set,\n" );
fprintf( stderr, "\t\tthen the -b flag is not required)\n" );
fprintf( stderr, " filter\tRFC-2254 compliant LDAP search filter\n" );
fprintf( stderr, " file\tfile containing a sequence of LDAP search filters to use\n" );
fprintf( stderr, " attributes\twhitespace-separated list of attributes to retrieve\n" );
fprintf( stderr, "\t\t(if no attribute list is given, all are retrieved)\n" );
fprintf( stderr, "options:\n" );
ldaptool_common_usage( 0 );
#if defined( XP_WIN32 )
fprintf( stderr, " -t\t\twrite values to files in temp directory.\n" );
#else
fprintf( stderr, " -t\t\twrite values to files in /tmp\n" );
#endif
fprintf( stderr, " -U\t\tproduce file URLs in conjunction with -t\n" );
fprintf( stderr, " -e\t\tminimize base-64 encoding of values\n" );
fprintf( stderr, " -u\t\tinclude User Friendly entry names in the output\n" );
fprintf( stderr, " -o\t\tprint entries using old format (default is LDIF)\n" );
fprintf( stderr, " -T\t\tdon't fold (wrap) long lines (default is to fold)\n" );
fprintf( stderr, " -1\t\tomit leading \"version: %d\" line in LDIF output\n", LDIF_VERSION_ONE );
fprintf( stderr, " -A\t\tretrieve attribute names only (no values)\n" );
fprintf( stderr, " -B\t\tprint non-ASCII values when old format (-o) is used\n" );
fprintf( stderr, " -x\t\tperforming sorting on server\n" );
fprintf( stderr, " -F sep\tprint `sep' instead of `=' between attribute names and values\n" );
fprintf( stderr, " -S attr\tsort the results by attribute `attr'\n" );
fprintf( stderr, " -s scope\tone of base, one, or sub (search scope)\n" );
fprintf( stderr, " -a deref\tone of never, always, search, or find (alias dereferencing)\n" );
fprintf( stderr, " -l time lim\ttime limit (in seconds) for search\n" );
fprintf( stderr, " -z size lim\tsize limit (in entries) for search\n" );
fprintf( stderr, " -G before:after:index:count | before:after:value where 'before' and\n");
fprintf( stderr, "\t\t'after' are the number of entries surrounding 'index.'\n");
fprintf( stderr, "\t\t'count' is the content count, 'value' is the search value.\n");
exit( LDAP_PARAM_ERROR );
}
static char *base = NULL;
static char *sep = LDAPTOOL_DEFSEP;
static char **sortattr = NULL;
static char *vlv_value = NULL;
static int sortsize = 0;
static int *skipsortattr = NULL;
static int includeufn, allow_binary, vals2tmp, ldif, scope, deref;
static int attrsonly, timelimit, sizelimit, server_sort, fold;
static int minimize_base64, produce_file_urls;
static int use_vlv = 0, vlv_before, vlv_after, vlv_index, vlv_count;
static int write_ldif_version = 1;
int
main( int argc, char **argv )
{
char *filtpattern, **attrs, line[ BUFSIZ ];
int rc, optind, i, first;
LDAP *ld;
deref = allow_binary = vals2tmp = attrsonly = 0;
minimize_base64 = produce_file_urls = 0;
ldif = 1;
fold = 1;
sizelimit = timelimit = 0;
scope = LDAP_SCOPE_SUBTREE;
server_sort = 0;
#ifdef HPUX11
#ifndef __LP64__
_main( argc, argv);
#endif /* __LP64_ */
#endif /* HPUX11 */
optind = ldaptool_process_args( argc, argv, "ABLTU1eotuxa:b:F:G:l:S:s:z:",
0, options_callback );
if ( base == NULL ) {
if (( base = getenv( "LDAP_BASEDN" )) == NULL ) {
usage();
}
}
if ( sortattr ) {
for ( sortsize = 0; sortattr[sortsize] != NULL; sortsize++ ) {
; /* NULL */
}
sortsize++; /* add in the final NULL field */
skipsortattr = (int *) malloc( sortsize * sizeof(int *) );
if ( skipsortattr == NULL ) {
fprintf( stderr, "Out of memory\n" );
exit( LDAP_NO_MEMORY );
}
memset( (char *) skipsortattr, 0, sortsize * sizeof(int *) );
} else if ( server_sort ) {
server_sort = 0; /* ignore this option if no sortattrs were given */
}
if ( argc - optind < 1 ) {
if ( ldaptool_fp == NULL ) {
usage();
}
attrs = NULL;
filtpattern = "%s";
} else { /* there are additional args (filter + attrs) */
if ( ldaptool_fp == NULL || strstr( argv[ optind ], "%s" ) != NULL ) {
filtpattern = ldaptool_local2UTF8( argv[ optind ] );
++optind;
} else {
filtpattern = "%s";
}
if ( argv[ optind ] == NULL ) {
attrs = NULL;
} else if ( sortattr == NULL || *sortattr == '\0' || server_sort) {
attrs = &argv[ optind ];
} else {
attrs = ldap_charray_dup( &argv[ optind ] );
if ( attrs == NULL ) {
fprintf( stderr, "Out of memory\n" );
exit( LDAP_NO_MEMORY );
}
for ( i = 0; i < (sortsize - 1); i++ ) {
if ( !ldap_charray_inlist( attrs, sortattr[i] ) ) {
if ( ldap_charray_add( &attrs, sortattr[i] ) != 0 ) {
fprintf( stderr, "Out of memory\n" );
exit( LDAP_NO_MEMORY );
}
/*
* attribute in the search list only for the purpose of
* sorting
*/
skipsortattr[i] = 1;
}
}
}
}
ld = ldaptool_ldap_init( 0 );
if ( !ldaptool_not ) {
ldap_set_option( ld, LDAP_OPT_DEREF, &deref );
ldap_set_option( ld, LDAP_OPT_TIMELIMIT, &timelimit );
ldap_set_option( ld, LDAP_OPT_SIZELIMIT, &sizelimit );
}
ldaptool_bind( ld );
if ( ldaptool_verbose ) {
printf( "filter pattern: %s\nreturning: ", filtpattern );
if ( attrs == NULL ) {
printf( "ALL" );
} else {
for ( i = 0; attrs[ i ] != NULL; ++i ) {
printf( "%s ", attrs[ i ] );
}
}
putchar( '\n' );
}
if ( ldaptool_fp == NULL ) {
char *conv;
conv = ldaptool_local2UTF8( base );
rc = dosearch( ld, conv, scope, attrs, attrsonly, filtpattern, "" );
if( conv != NULL )
free( conv );
} else {
rc = LDAP_SUCCESS;
first = 1;
while ( rc == LDAP_SUCCESS &&
fgets( line, sizeof( line ), ldaptool_fp ) != NULL ) {
line[ strlen( line ) - 1 ] = '\0';
if ( !first ) {
putchar( '\n' );
} else {
first = 0;
}
rc = dosearch( ld, base, scope, attrs, attrsonly, filtpattern,
line );
}
}
ldaptool_cleanup( ld );
return( rc );
}
static void
options_callback( int option, char *optarg )
{
char *s;
switch( option ) {
case 'u': /* include UFN */
++includeufn;
break;
case 't': /* write attribute values to /tmp files */
++vals2tmp;
break;
case 'U': /* produce file URLs in conjunction with -t */
++produce_file_urls;
break;
case 'e': /* minimize base-64 encoding of values */
++minimize_base64;
break;
case 'A': /* retrieve attribute names only -- no values */
++attrsonly;
break;
case 'L': /* print entries in LDIF format -- now the default */
break;
case 'o': /* print entries using old ldapsearch format */
ldif = 0;
break;
case 'B': /* allow binary values to be printed, even if -o used */
++allow_binary;
break;
case '1': /* omit leading "version: #" line from LDIF output */
write_ldif_version = 0;
break;
case 's': /* search scope */
if ( strncasecmp( optarg, "base", 4 ) == 0 ) {
scope = LDAP_SCOPE_BASE;
} else if ( strncasecmp( optarg, "one", 3 ) == 0 ) {
scope = LDAP_SCOPE_ONELEVEL;
} else if ( strncasecmp( optarg, "sub", 3 ) == 0 ) {
scope = LDAP_SCOPE_SUBTREE;
} else {
fprintf( stderr, "scope should be base, one, or sub\n" );
usage();
}
break;
case 'a': /* set alias deref option */
if ( strncasecmp( optarg, "never", 5 ) == 0 ) {
deref = LDAP_DEREF_NEVER;
} else if ( strncasecmp( optarg, "search", 5 ) == 0 ) {
deref = LDAP_DEREF_SEARCHING;
} else if ( strncasecmp( optarg, "find", 4 ) == 0 ) {
deref = LDAP_DEREF_FINDING;
} else if ( strncasecmp( optarg, "always", 6 ) == 0 ) {
deref = LDAP_DEREF_ALWAYS;
} else {
fprintf( stderr, "alias deref should be never, search, find, or always\n" );
usage();
}
break;
case 'F': /* field separator */
sep = strdup( optarg );
break;
case 'b': /* searchbase */
base = strdup( optarg );
break;
case 'l': /* time limit */
timelimit = atoi( optarg );
break;
case 'x': /* server sorting requested */
server_sort = 1;
break;
case 'z': /* size limit */
sizelimit = atoi( optarg );
break;
case 'S': /* sort attribute */
ldap_charray_add( &sortattr, strdup( optarg ) );
break;
case 'T': /* don't fold lines */
fold = 0;
break;
case 'G': /* do the virtual list setup */
use_vlv++;
s = strchr(optarg, VLV_PARAM_SEP );
if (s != NULL)
{
vlv_before = atoi(optarg);
s++;
vlv_after = atoi( s );
s = strchr(s, VLV_PARAM_SEP );
if (s != NULL)
{
s++;
/* below is a small set of logic to implement the following cases
* -G23:23:wilber
* -G23:23:"wilber:wright"
* -G23:23:'wilber'
* -G23:23:wilber wright
* all of the above are before, after, value - NOTE: a colon not in a quoted
* string will break the parser!!!!
* -G23:23:45:600
* above is index, count encoding
*/
if (*s == '\'' || *s == '"')
{
vlv_value = strdup( s );
}
else
{
if (strchr( s, VLV_PARAM_SEP ))
{
/* we have an index + count option */
vlv_index = atoi( s );
vlv_count = atoi( strchr( s, VLV_PARAM_SEP) + 1);
}
else
{
/* we don't have a quote surrounding the assertion value
* do we need to???
*/
vlv_value = strdup( s );
}
}
}
else
{
fprintf( stderr,"Illegal 'after' paramater for virtual list\n" );
exit( LDAP_PARAM_ERROR );
}
}
else
{
fprintf( stderr,"Illegal 'before' paramater for virtual list\n" );
exit( LDAP_PARAM_ERROR );
}
break;
default:
usage();
break;
}
}
static int
dosearch( ld, base, scope, attrs, attrsonly, filtpatt, value )
LDAP *ld;
char *base;
int scope;
char **attrs;
int attrsonly;
char *filtpatt;
char *value;
{
char **refs = NULL, filter[ BUFSIZ ];
int rc, first, matches;
LDAPMessage *res, *e;
LDAPControl *ldctrl;
LDAPControl **ctrl_response_array = NULL;
LDAPVirtualList vlv_data;
int msgid = 0;
#ifdef HAVE_SNPRINTF
if ( snprintf( filter, sizeof(filter), filtpatt, value ) < 0 ) {
perror( "snprintf filter (filter and/or pattern too long?)" );
exit( LDAP_PARAM_ERROR );
}
#else
sprintf( filter, filtpatt, value );
#endif
if ( *filter == '\0' ) { /* treat empty filter is a shortcut for oc=* */
strcpy( filter, "(objectclass=*)" );
}
if ( ldaptool_verbose ) {
printf( "filter is: (%s)\n", filter );
}
if ( ldaptool_not ) {
return( LDAP_SUCCESS );
}
if (( ldctrl = ldaptool_create_manage_dsait_control()) != NULL ) {
ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls);
}
if ((ldctrl = ldaptool_create_proxyauth_control(ld)) !=NULL) {
ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls);
}
if (server_sort) {
/* First make a sort key list from the attribute list we have */
LDAPsortkey **keylist = NULL;
int i = 0;
char *sortattrs = NULL;
char *s = NULL;
int string_length = 0;
/* Count the sort strings */
for (i = 0; i < sortsize - 1 ; i++) {
string_length += strlen(sortattr[i]) + 1;
}
sortattrs = (char *) malloc(string_length + 1);
if (NULL == sortattrs) {
fprintf( stderr, "Out of memory\n" );
exit( LDAP_NO_MEMORY );
}
s = sortattrs;
for (i = 0; i < sortsize - 1 ; i++) {
memcpy(s, sortattr[i], strlen(sortattr[i]));
s += strlen(sortattr[i]);
*s++ = ' ';
}
sortattrs[string_length] = '\0';
ldap_create_sort_keylist(&keylist,sortattrs);
free(sortattrs);
sortattrs = NULL;
/* Then make a control for the sort attributes we have */
rc = ldap_create_sort_control(ld,keylist,0,&ldctrl);
ldap_free_sort_keylist(keylist);
if ( rc != LDAP_SUCCESS ) {
return( ldaptool_print_lderror( ld, "ldap_create_sort_control",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls);
}
/* remember server side sorting must be available for vlv!!!! */
if (use_vlv)
{
vlv_data.ldvlist_before_count = vlv_before;
vlv_data.ldvlist_after_count = vlv_after;
if ( ldaptool_verbose ) {
printf( "vlv data %lu, %lu, ",
vlv_data.ldvlist_before_count,
vlv_data.ldvlist_after_count
);
}
if (vlv_value)
{
vlv_data.ldvlist_attrvalue = vlv_value;
vlv_data.ldvlist_size = 0;
vlv_data.ldvlist_index = 0;
if ( ldaptool_verbose ) {
printf( "%s, 0, 0\n", vlv_data.ldvlist_attrvalue);
}
}
else
{
vlv_data.ldvlist_attrvalue = NULL;
vlv_data.ldvlist_size = vlv_count;
vlv_data.ldvlist_index = vlv_index;
if ( ldaptool_verbose ) {
printf( "(null), %lu, %lu\n", vlv_data.ldvlist_size, vlv_data.ldvlist_index );
}
}
if ( rc != LDAP_SUCCESS ) {
return( ldaptool_print_lderror( ld, "ldap_create_sort_control",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
if (LDAP_SUCCESS != (rc = ldap_create_virtuallist_control(ld,
&vlv_data, &ldctrl)))
{
return( ldaptool_print_lderror( ld,
"ldap_create_virtuallist_control",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
ldaptool_add_control_to_array(ldctrl, ldaptool_request_ctrls);
}
if ( ldap_search_ext( ld, base, scope, filter, attrs, attrsonly,
ldaptool_request_ctrls, NULL, NULL, -1, &msgid )
!= LDAP_SUCCESS ) {
return( ldaptool_print_lderror( ld, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
ldaptool_reset_control_array( ldaptool_request_ctrls );
matches = 0;
first = 1;
if ( sortattr && !server_sort ) {
rc = ldap_result( ld, LDAP_RES_ANY, 1, NULL, &res );
} else {
while ( (rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res )) !=
LDAP_RES_SEARCH_RESULT && rc != -1 ) {
if ( rc != LDAP_RES_SEARCH_ENTRY ) {
if ( rc == LDAP_RES_SEARCH_REFERENCE ) {
parse_and_display_reference( ld, res );
} else if ( rc == LDAP_RES_EXTENDED
&& ldap_msgid( res ) == LDAP_RES_UNSOLICITED ) {
ldaptool_print_extended_response( ld, res,
"Unsolicited response" );
} else {
fprintf( stderr, "%s: ignoring LDAP response message"
" type 0x%x (%s)\n",
ldaptool_progname, rc, msgtype2str( rc ));
}
ldap_msgfree( res );
continue;
}
matches++;
e = ldap_first_entry( ld, res );
if ( !first ) {
putchar( '\n' );
} else {
first = 0;
}
print_entry( ld, e, attrsonly );
ldap_msgfree( res );
}
}
if ( rc == -1 ) {
return( ldaptool_print_lderror( ld, "ldap_result",
LDAPTOOL_CHECK4SSL_IF_APPROP ));
}
if ( ldap_parse_result( ld, res, &rc, NULL, NULL, &refs,
&ctrl_response_array, 0 ) != LDAP_SUCCESS ) {
ldaptool_print_lderror( ld, "ldap_parse_result",
LDAPTOOL_CHECK4SSL_IF_APPROP );
} else if ( rc != LDAP_SUCCESS ) {
ldaptool_print_lderror( ld, "ldap_search",
LDAPTOOL_CHECK4SSL_IF_APPROP );
}
/* Parse the returned sort control */
if (server_sort) {
unsigned long result = 0;
char *attribute;
if ( LDAP_SUCCESS != ldap_parse_sort_control(ld,ctrl_response_array,&result,&attribute) ) {
ldaptool_print_lderror(ld, "ldap_parse_sort_control",
LDAPTOOL_CHECK4SSL_IF_APPROP );
ldap_controls_free(ctrl_response_array);
ldap_msgfree(res);
return ( ldap_get_lderrno( ld, NULL, NULL ) );
}
if (0 == result) {
if ( ldaptool_verbose ) {
printf( "Server indicated results sorted OK\n");
}
} else {
if (NULL != attribute) {
printf("Server reported sorting error %ld: %s, attribute in error\"%s\"\n",result,sortresult2string(result),attribute);
} else {
printf("Server reported sorting error %ld: %s\n",result,sortresult2string(result));
}
}
}
if (use_vlv)
{
unsigned long vpos, vcount;
int vresult;
if ( LDAP_SUCCESS != ldap_parse_virtuallist_control(ld,ctrl_response_array,&vpos, &vcount,&vresult) ) {
ldaptool_print_lderror( ld, "ldap_parse_virtuallist_control",
LDAPTOOL_CHECK4SSL_IF_APPROP );
ldap_controls_free(ctrl_response_array);
ldap_msgfree(res);
return ( ldap_get_lderrno( ld, NULL, NULL ) );
}
if (0 == vresult) {
if ( ldaptool_verbose ) {
printf( "Server indicated virtual list positioning OK\n");
}
printf("index %lu content count %lu\n", vpos, vcount);
} else {
printf("Server reported sorting error %d: %s\n",vresult,sortresult2string(vresult));
}
}
ldap_controls_free(ctrl_response_array);
if ( sortattr != NULL && !server_sort) {
(void) ldap_multisort_entries( ld, &res,
( *sortattr == NULL ) ? NULL : sortattr,
(LDAP_CMP_CALLBACK *)strcasecmp );
matches = 0;
first = 1;
for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
e = ldap_next_entry( ld, e ) ) {
matches++;
if ( !first ) {
putchar( '\n' );
} else {
first = 0;
}
print_entry( ld, e, attrsonly );
}
}
if ( ldaptool_verbose ) {
printf( "%d matches\n", matches );
}
if ( refs != NULL ) {
ldaptool_print_referrals( refs );
ldap_value_free( refs );
}
ldap_msgfree( res );
return( rc );
}
static void
print_entry( ld, entry, attrsonly )
LDAP *ld;
LDAPMessage *entry;
int attrsonly;
{
char *a, *dn, *ufn, tmpfname[ BUFSIZ ];
int i, notascii;
BerElement *ber;
struct berval **bvals;
FILE *tmpfp;
#if defined( XP_WIN32 )
char mode[20] = "w+b";
#else
char mode[20] = "w";
#endif
dn = ldap_get_dn( ld, entry );
if ( ldif ) {
write_ldif_value( "dn", dn, strlen( dn ), 0 );
} else {
printf( "%s\n", dn );
}
if ( includeufn ) {
ufn = ldap_dn2ufn( dn );
if ( ldif ) {
write_ldif_value( "ufn", ufn, strlen( ufn ), 0 );
} else {
printf( "%s\n", ufn );
}
free( ufn );
}
ldap_memfree( dn );
for ( a = ldap_first_attribute( ld, entry, &ber ); a != NULL;
a = ldap_next_attribute( ld, entry, ber ) ) {
if ( ldap_charray_inlist(sortattr, a) && /* in the list*/
skipsortattr[ldap_charray_position(sortattr, a)] ) {/* and skip it*/
continue; /* so skip it! */
}
if ( attrsonly ) {
if ( ldif ) {
write_ldif_value( a, "", 0, 0 );
} else {
printf( "%s\n", a );
}
} else if (( bvals = ldap_get_values_len( ld, entry, a )) != NULL ) {
for ( i = 0; bvals[i] != NULL; i++ ) {
if ( vals2tmp ) {
#ifdef HAVE_SNPRINTF
if ( snprintf( tmpfname, sizeof(tmpfname),
"%s/ldapsearch-%s-XXXXXX",
ldaptool_get_tmp_dir(), a ) < 0 ) {
perror( "snprintf tmpfname (attribute name too long?)" );
exit( LDAP_PARAM_ERROR );
}
#else
sprintf( tmpfname, "%s/ldapsearch-%s-XXXXXX",
ldaptool_get_tmp_dir(), a );
#endif
tmpfp = NULL;
if ( mktemp( tmpfname ) == NULL ) {
perror( tmpfname );
} else if (( tmpfp = fopen( tmpfname, mode)) == NULL ) {
perror( tmpfname );
} else if ( bvals[ i ]->bv_len > 0 &&
fwrite( bvals[ i ]->bv_val,
bvals[ i ]->bv_len, 1, tmpfp ) == 0 ) {
perror( tmpfname );
} else if ( ldif ) {
if ( produce_file_urls ) {
char *url;
if ( ldaptool_path2fileurl( tmpfname, &url ) !=
LDAPTOOL_FILEURL_SUCCESS ) {
perror( "ldaptool_path2fileurl" );
} else {
write_ldif_value( a, url, strlen( url ),
LDIF_OPT_VALUE_IS_URL );
free( url );
}
} else {
write_ldif_value( a, tmpfname, strlen( tmpfname ),
0 );
}
} else {
printf( "%s%s%s\n", a, sep, tmpfname );
}
if ( tmpfp != NULL ) {
fclose( tmpfp );
}
} else {
notascii = 0;
if ( !ldif && !allow_binary ) {
unsigned long j;
for ( j = 0; j < bvals[ i ]->bv_len; ++j ) {
if ( !isascii( bvals[ i ]->bv_val[ j ] )) {
notascii = 1;
break;
}
}
}
if ( ldif ) {
write_ldif_value( a, bvals[ i ]->bv_val,
bvals[ i ]->bv_len, 0 );
} else {
printf( "%s%s%s\n", a, sep,
notascii ? "NOT ASCII" : bvals[ i ]->bv_val );
}
}
}
ber_bvecfree( bvals );
}
ldap_memfree( a );
}
if ( ldap_get_lderrno( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldaptool_print_lderror( ld, "ldap_first_attribute/ldap_next_attribute",
LDAPTOOL_CHECK4SSL_IF_APPROP );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
}
static int
write_ldif_value( char *type, char *value, unsigned long vallen,
unsigned long ldifoptions )
{
char *ldif;
static int wrote_version = 0;
if ( write_ldif_version && !wrote_version ) {
char versionbuf[ 64 ];
wrote_version = 1;
sprintf( versionbuf, "%d", LDIF_VERSION_ONE );
write_ldif_value( "version", versionbuf, strlen( versionbuf ), 0 );
}
if ( !fold ) {
ldifoptions |= LDIF_OPT_NOWRAP;
}
if ( minimize_base64 ) {
ldifoptions |= LDIF_OPT_MINIMAL_ENCODING;
}
if (( ldif = ldif_type_and_value_with_options( type, value, (int)vallen,
ldifoptions )) == NULL ) {
return( -1 );
}
fputs( ldif, stdout );
free( ldif );
return( 0 );
}
static char *
sortresult2string(unsigned long result)
{
/*
success (0), -- results are sorted
operationsError (1), -- server internal failure
timeLimitExceeded (3), -- timelimit reached before
-- sorting was completed
strongAuthRequired (8), -- refused to return sorted
-- results via insecure
-- protocol
adminLimitExceeded (11), -- too many matching entries
-- for the server to sort
noSuchAttribute (16), -- unrecognized attribute
-- type in sort key
inappropriateMatching (18), -- unrecognized or inappro-
-- priate matching rule in
-- sort key
insufficientAccessRights (50), -- refused to return sorted
-- results to this client
busy (51), -- too busy to process
unwillingToPerform (53), -- unable to sort
other (80)
*/
switch (result) {
case 0: return ("success");
case 1: return ("operations error");
case 3: return ("time limit exceeded");
case 8: return ("strong auth required");
case 11: return ("admin limit exceeded");
case 16: return ("no such attribute");
case 18: return ("unrecognized or inappropriate matching rule");
case 50: return ("insufficient access rights");
case 51: return ("too busy");
case 53: return ("unable to sort");
case 80:
default: return ("Er...Other ?");
}
}
static void
parse_and_display_reference( LDAP *ld, LDAPMessage *ref )
{
int i;
char **refs;
if ( ldap_parse_reference( ld, ref, &refs, NULL, 0 ) != LDAP_SUCCESS ) {
ldaptool_print_lderror( ld, "ldap_parse_reference",
LDAPTOOL_CHECK4SSL_IF_APPROP );
} else if ( refs != NULL && refs[ 0 ] != NULL ) {
fputs( "Unfollowed continuation reference(s):\n", stderr );
for ( i = 0; refs[ i ] != NULL; ++i ) {
fprintf( stderr, " %s\n", refs[ i ] );
}
ldap_value_free( refs );
}
}
/*possible operations a client can invoke -- copied from ldaprot.h */
#ifndef LDAP_REQ_BIND
#define LDAP_REQ_BIND 0x60L /* application + constructed */
#define LDAP_REQ_UNBIND 0x42L /* application + primitive */
#define LDAP_REQ_SEARCH 0x63L /* application + constructed */
#define LDAP_REQ_MODIFY 0x66L /* application + constructed */
#define LDAP_REQ_ADD 0x68L /* application + constructed */
#define LDAP_REQ_DELETE 0x4aL /* application + primitive */
#define LDAP_REQ_RENAME 0x6cL /* application + constructed */
#define LDAP_REQ_COMPARE 0x6eL /* application + constructed */
#define LDAP_REQ_ABANDON 0x50L /* application + primitive */
#define LDAP_REQ_EXTENDED 0x77L /* application + constructed */
#endif /* LDAP_REQ_BIND */
struct ldapsearch_type2str {
int ldst2s_type; /* message type */
char *ldst2s_string; /* descriptive string */
};
static struct ldapsearch_type2str ldapsearch_msgtypes[] = {
/* results: */
{ LDAP_RES_BIND, "bind result" },
{ LDAP_RES_SEARCH_REFERENCE, "continuation reference" },
{ LDAP_RES_SEARCH_ENTRY, "entry" },
{ LDAP_RES_SEARCH_RESULT, "search result" },
{ LDAP_RES_MODIFY, "modify result" },
{ LDAP_RES_ADD, "add result" },
{ LDAP_RES_DELETE, "delete result" },
{ LDAP_RES_MODDN, "rename result" },
{ LDAP_RES_COMPARE, "compare result" },
{ LDAP_RES_EXTENDED, "extended operation result" },
/* requests: */
{ LDAP_REQ_BIND, "bind request" },
{ LDAP_REQ_UNBIND, "unbind request" },
{ LDAP_REQ_SEARCH, "search request" },
{ LDAP_REQ_MODIFY, "modify request" },
{ LDAP_REQ_ADD, "add request" },
{ LDAP_REQ_DELETE, "delete request" },
{ LDAP_REQ_RENAME, "rename request" },
{ LDAP_REQ_COMPARE, "compare request" },
{ LDAP_REQ_ABANDON, "abandon request" },
{ LDAP_REQ_EXTENDED, "extended request" },
};
#define LDAPSEARCHTOOL_NUMTYPES (sizeof(ldapsearch_msgtypes) \
/ sizeof(struct ldapsearch_type2str))
/*
* Return a descriptive string given an LDAP result message type (tag).
*/
static char *
msgtype2str( int msgtype )
{
char *s = "unknown";
int i;
s = "unknown";
for ( i = 0; i < LDAPSEARCHTOOL_NUMTYPES; ++i ) {
if ( msgtype == ldapsearch_msgtypes[ i ].ldst2s_type ) {
s = ldapsearch_msgtypes[ i ].ldst2s_string;
}
}
return( s );
}

View File

@@ -0,0 +1,130 @@
#ifndef _LDAPTOOL_H
#define _LDAPTOOL_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#ifdef AIX
#include <strings.h>
#endif
#ifdef SCOOS
#include <sys/types.h>
#endif
#ifdef _WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
extern int getopt (int argc, char *const *argv, const char *optstring);
#else
#include <sys/file.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include <ctype.h>
#ifndef SCOOS
#include <sys/types.h>
#endif
#include <sys/stat.h>
#include <fcntl.h>
#if defined(NET_SSL)
#include <ssl.h>
#endif
#include <portable.h>
#include <ldap.h>
#ifndef NO_LIBLCACHE
#include <lcache.h>
#endif
#include <ldaplog.h>
#include <ldif.h>
#if defined(NET_SSL)
#include <ldap_ssl.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* shared macros, structures, etc.
*/
#define LDAPTOOL_DEFSEP "=" /* used by ldapcmp and ldapsearch */
#define LDAPTOOL_DEFHOST "localhost"
#define LDAPTOOL_SAFEREALLOC( ptr, size ) ( ptr == NULL ? malloc( size ) : \
realloc( ptr, size ))
/* this defines the max number of control requests for the tools */
#define CONTROL_REQUESTS 5
/*
* globals (defined in common.c)
*/
extern char *ldaptool_host;
extern char *ldaptool_host2;
extern int ldaptool_port;
extern int ldaptool_port2;
extern int ldaptool_verbose;
extern int ldaptool_not;
extern char *ldaptool_progname;
extern FILE *ldaptool_fp;
extern char *ldaptool_charset;
extern char *ldaptool_convdir;
extern LDAPControl *ldaptool_request_ctrls[];
/*
* function prototypes
*/
void ldaptool_common_usage( int two_hosts );
int ldaptool_process_args( int argc, char **argv, char *extra_opts,
int two_hosts, void (*extra_opt_callback)( int option, char *optarg ));
LDAP *ldaptool_ldap_init( int second_host );
void ldaptool_bind( LDAP *ld );
void ldaptool_cleanup( LDAP *ld );
int ldaptool_print_lderror( LDAP *ld, char *msg, int check4ssl );
#define LDAPTOOL_CHECK4SSL_NEVER 0
#define LDAPTOOL_CHECK4SSL_ALWAYS 1
#define LDAPTOOL_CHECK4SSL_IF_APPROP 2 /* if appropriate */
LDAPControl *ldaptool_create_manage_dsait_control( void );
void ldaptool_print_referrals( char **refs );
int ldaptool_print_extended_response( LDAP *ld, LDAPMessage *res, char *msg );
LDAPControl *ldaptool_create_proxyauth_control( LDAP *ld );
void ldaptool_add_control_to_array( LDAPControl *ctrl, LDAPControl **array);
void ldaptool_reset_control_array( LDAPControl **array );
char *ldaptool_get_tmp_dir( void );
char *ldaptool_local2UTF8( const char * );
int ldaptool_sasl_bind_s( LDAP *ld, const char *dn, const char *mechanism,
const struct berval *cred, LDAPControl **serverctrls,
LDAPControl **clientctrls, struct berval **servercredp, char *msg );
int ldaptool_simple_bind_s( LDAP *ld, const char *dn, const char *passwd,
LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg );
int ldaptool_add_ext_s( LDAP *ld, const char *dn, LDAPMod **attrs,
LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg );
int ldaptool_modify_ext_s( LDAP *ld, const char *dn, LDAPMod **mods,
LDAPControl **serverctrls, LDAPControl **clientctrls, char *msg );
int ldaptool_delete_ext_s( LDAP *ld, const char *dn, LDAPControl **serverctrls,
LDAPControl **clientctrls, char *msg );
int ldaptool_rename_s( LDAP *ld, const char *dn, const char *newrdn,
const char *newparent, int deleteoldrdn, LDAPControl **serverctrls,
LDAPControl **clientctrls, char *msg );
#ifdef __cplusplus
}
#endif
#endif /* LDAPTOOL_H */

View File

@@ -0,0 +1,97 @@
/******************************************************
*
* Copyright (c) 1996 Netscape Communications Corp.
* This code is proprietary and is a trade secret of
* Netscape Communications Corp.
*
* ntuserpin.c - Prompts for the key
* database passphrase.
*
******************************************************/
#if defined( _WIN32 ) && defined ( NET_SSL )
#include <conio.h>
#include "ntuserpin.h"
#undef Debug
#undef OFF
#undef LITTLE_ENDIAN
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
static int i=0;
static int cbRemotePassword = 0;
static const char nt_retryWarning[] =
"Warning: You entered an incorrect PIN.\nIncorrect PIN may result in disabling the token";
static const char prompt[] = "Enter PIN for";
#define SZ_LOCAL_PWD 1024
static char loclpwd[SZ_LOCAL_PWD] = "";
struct SVRCORENTUserPinObj
{
SVRCOREPinObj base;
};
static const struct SVRCOREPinMethods vtable;
/* ------------------------------------------------------------ */
SVRCOREError
SVRCORE_CreateNTUserPinObj(SVRCORENTUserPinObj **out)
{
SVRCOREError err = 0;
SVRCORENTUserPinObj *obj = 0;
do {
obj = (SVRCORENTUserPinObj*)malloc(sizeof (SVRCORENTUserPinObj));
if (!obj) { err = 1; break; }
obj->base.methods = &vtable;
} while(0);
if (err)
{
SVRCORE_DestroyNTUserPinObj(obj);
obj = 0;
}
*out = obj;
return err;
}
void
SVRCORE_DestroyNTUserPinObj(SVRCORENTUserPinObj *obj)
{
if (obj) free(obj);
}
static void destroyObject(SVRCOREPinObj *obj)
{
SVRCORE_DestroyNTUserPinObj((SVRCORENTUserPinObj*)obj);
}
static char *getPin(SVRCOREPinObj *obj, const char *tokenName, PRBool retry)
{
char *pwd;
int ch;
if (retry)
printf("%s\n",nt_retryWarning);
printf("%s %s:", prompt, tokenName);
pwd = &loclpwd[0];
do
{
ch = _getch();
*pwd++ = (char )ch;
} while( ch != '\r' && (pwd < &loclpwd[SZ_LOCAL_PWD - 1]));
*(pwd-1)='\0';
printf("\n");
/* test for zero length password. if zero length, return null */
if ('\0' == loclpwd[0])
return NULL;
return &loclpwd[0];
}
/*
* VTable
*/
static const SVRCOREPinMethods vtable =
{ 0, 0, destroyObject, getPin };
#endif /* defined( _WIN32 ) && defined ( NET_SSL ) */

View File

@@ -0,0 +1,25 @@
/******************************************************
*
* Copyright (c) 1996 Netscape Communications Corp.
* This code is proprietary and is a trade secret of
* Netscape Communications Corp.
*
* ntuserpin.h - Prompts for the key
* database passphrase.
*
******************************************************/
#ifndef _NTUSERPIN_H_
#define _NTUSERPIN_H_
#include "svrcore.h"
typedef struct SVRCORENTUserPinObj SVRCORENTUserPinObj;
SVRCOREError
SVRCORE_CreateNTUserPinObj(SVRCORENTUserPinObj **out);
void
SVRCORE_SetNTUserPinInteractive(SVRCORENTUserPinObj *obj, PRBool interactive);
void
SVRCORE_DestroyNTUserPinObj(SVRCORENTUserPinObj *obj);
#endif

File diff suppressed because it is too large Load Diff

798
mozilla/directory/c-sdk/ldap/configure vendored Executable file
View File

@@ -0,0 +1,798 @@
#! /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-nspr-autoconf Enable building with an autoconf'ed NSPR tree"
# 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=build/dirver.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
# Check whether --enable-nspr-autoconf or --disable-nspr-autoconf was given.
if test "${enable_nspr_autoconf+set}" = set; then
enableval="$enable_nspr_autoconf"
NSPR_USE_AUTOCONF=1
else
NSPR_USE_AUTOCONF=0
fi
MAKEFILES="
Makefile
build/Makefile
build/autoconf.mk
include/Makefile
libraries/Makefile
libraries/libldap/Makefile
libraries/liblber/Makefile
"
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
trap 'rm -fr `echo "$MAKEFILES" | 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%@NSPR_USE_AUTOCONF@%$NSPR_USE_AUTOCONF%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-"$MAKEFILES"}
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
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
" $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

View File

@@ -0,0 +1,50 @@
dnl
dnl The contents of this file are subject to the Mozilla Public
dnl License Version 1.1 (the "License"); you may not use this file
dnl except in compliance with the License. You may obtain a copy of
dnl the License at http://www.mozilla.org/MPL/
dnl
dnl Software distributed under the License is distributed on an "AS
dnl IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
dnl implied. See the License for the specific language governing
dnl rights and limitations under the License.
dnl
dnl The Original Code is mozilla.org LDAP SDK autoconf glue.
dnl
dnl The Initial Developer of the Original Code is Netscape
dnl Communications Corp. Portions created by Netscape are
dnl Copyright (C) 2000, Netscape Communications Corp. All
dnl Rights Reserved.
dnl
dnl Contributor(s): Dan Mosedale <dmose@mozilla.org>
dnl
dnl Process this file with autoconf to produce a configure script.
AC_INIT(build/dirver.c)
dnl Checks for programs.
dnl Checks for libraries.
dnl Checks for header files.
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
dnl If the nsprpub whose configuration system we're using has been built with
dnl --enable-nspr-autoconf, we need to cope with that here.
dnl
AC_ARG_ENABLE(nspr-autoconf,
[ --enable-nspr-autoconf Enable building with an autoconf'ed NSPR tree],
NSPR_USE_AUTOCONF=1, NSPR_USE_AUTOCONF=0)
AC_SUBST(NSPR_USE_AUTOCONF)
dnl Generate output files
dnl
MAKEFILES="
Makefile
build/Makefile
build/autoconf.mk
include/Makefile
libraries/Makefile
libraries/libldap/Makefile
libraries/liblber/Makefile
"
AC_OUTPUT([$MAKEFILES])

View File

@@ -0,0 +1,230 @@
#
# Copyright (c) 1996-1998. Netscape Communications Corporation. All
# rights reserved.
#
#
# UNIX Makefile for Directory SDK examples
#
# SSL examples are not built by default. Use 'make ssl' to build them.
# NSPR examples are not built by default. Use 'make nspr' to build them.
#
###############################################################################
# If you are not building on Solaris, you will need to comment out the
# Solaris section and uncomment the appropriate section for your platform.
#
# Also note that the LDAP API library has different names for the SSL-enabled
# and non-SSL versions of the Directory SDK for C:
#
# o In the SSL-enabled version, the library is named
# libldapssl41.so on Solaris, IRIX, and AIX, and
# libldapssl41.sl on HP-UX.
#
# o In the non-SSL version, the library is named
# libldap41.so on Solaris, IRIX, and AIX, and
# libldap41.sl on HP-UX.
#
# Remove the comment character in front of the definition of
# LDAPLIB that matches the name of the LDAP API library for the
# version you've downloaded.
#
# For Solaris
EXTRACFLAGS=
EXTRALDFLAGS=-lsocket -lnsl
EXTRANSPRLDFLAGS=-mt
LDAPLIB=ldapssl41
#LDAPLIB=ldap41
LDAPPRLIB=ldappr41
NSPRLIB=nspr3
CC=cc
# For HP/UX (32 bit)
#EXTRACFLAGS=-Dhpux -D_HPUX_SOURCE -D_REENTRANT -Aa
#EXTRALDFLAGS=-Wl,+s+b
#LDAPLIB=ldapssl41
#LDAPLIB=ldap41
#LDAPPRLIB=ldappr41
#NSPRLIB=nspr3
#CC=cc
# For HP/UX (64 bit)
#EXTRACFLAGS=-DHPUX11 -DIS_64 +e +DA2.0W +DChpux +DS2.0
#EXTRACFLAGS+=-D_LARGEFILE64_SOURCE -D_PR_HAVE_OFF64_T
#EXTRALDFLAGS=-lpthread +DA2.0W +DS2.0
#LDAPLIB=ldapssl41
#LDAPLIB=ldap41
#LDAPPRLIB=ldappr41
#NSPRLIB=nspr3
#CC=/opt/ansic/bin/cc
# For IRIX
#EXTRACFLAGS=
#EXTRALDFLAGS=
#LDAPLIB=ldapssl41
#LDAPLIB=ldap41
#LDAPPRLIB=ldappr41
#NSPRLIB=nspr3
#CC=cc
# For AIX
#EXTRACFLAGS=
#EXTRALDFLAGS=-brtl
#LDAPLIB=ldapssl41
#LDAPLIB=ldap41
#LDAPPRLIB=ldappr41
#NSPRLIB=nspr3
#CC=cc
# For Digital UNIX 4.0
#EXTRACFLAGS=
#EXTRALDFLAGS=-taso -rpath ../lib
#LDAPLIB=ldapssl41
#LDAPLIB=ldap41
#LDAPPRLIB=ldappr41
#NSPRLIB=nspr3
#CC=cc
# For Linux 2.2
#EXTRACFLAGS=
#EXTRALDFLAGS=-lpthread
#LDAPLIB=ldapssl41
#LDAPLIB=ldap41
#LDAPPRLIB=ldappr41
#NSPRLIB=nspr3
#CC=gcc
###############################################################################
# You should not need to change anything below here....
INCDIR=../include
LIBDIR=../lib
NSPRINCDIR=../include
NSPRLIBDIR=../lib
LIBS=-L$(LIBDIR) -l$(LDAPLIB) $(EXTRALDFLAGS)
NSPRLIBS=$(EXTRANSPRLDFLAGS) -L$(NSPRLIBDIR) -l$(NSPRLIB) -l$(LDAPPRLIB)
OPTFLAGS=-g
CFLAGS=$(OPTFLAGS) -I$(INCDIR) -I$(NSPRINCDIR) $(EXTRACFLAGS)
NSPRCFLAGS=-I$(NSPRINCDIR)
PROGS=search asearch csearch psearch rdentry getattrs srvrsort modattrs add del compare modrdn ppolicy getfilt crtfilt
SSLPROGS=ssnoauth ssearch
NSPRPROGS=nsprio
ALLPROGS= $(PROGS)
standard: $(PROGS)
ssl: $(SSLPROGS)
nspr: $(NSPRPROGS)
all: $(ALLPROGS)
purify: $(PROGS)
make clean; make CC="purify $(CC)"
search: search.o
$(CC) -o search search.o $(LIBS)
search.o: examples.h
csearch: csearch.o
$(CC) -o csearch csearch.o $(LIBS)
csearch.o: examples.h
psearch: psearch.o
$(CC) -o psearch psearch.o $(LIBS)
psearch.o: examples.h
ssearch: ssearch.o
$(CC) -o ssearch ssearch.o $(LIBS)
ssearch.o: examples.h
ssnoauth: ssnoauth.o
$(CC) -o ssnoauth ssnoauth.o $(LIBS)
ssnoauth.o: examples.h
rdentry: rdentry.o
$(CC) -o rdentry rdentry.o $(LIBS)
rdentry.o: examples.h
getattrs: getattrs.o
$(CC) -o getattrs getattrs.o $(LIBS)
getattrs.o: examples.h
srvrsort: srvrsort.o
$(CC) -o srvrsort srvrsort.o $(LIBS)
srvrsort.o: examples.h
modattrs: modattrs.o
$(CC) -o modattrs modattrs.o $(LIBS)
modattrs.o: examples.h
asearch: asearch.o
$(CC) -o asearch asearch.o $(LIBS)
asearch.o: examples.h
add: add.o
$(CC) -o add add.o $(LIBS)
add.o: examples.h
del: del.o
$(CC) -o del del.o $(LIBS)
del.o: examples.h
compare: compare.o
$(CC) -o compare compare.o $(LIBS)
compare.o: examples.h
modrdn: modrdn.o
$(CC) -o modrdn modrdn.o $(LIBS)
modrdn.o: examples.h
ppolicy: ppolicy.o
$(CC) -o ppolicy ppolicy.o $(LIBS)
ppolicy.o: examples.h
getfilt: getfilt.o
$(CC) -o getfilt getfilt.o $(LIBS)
getfilt.o: examples.h
crtfilt: crtfilt.o
$(CC) -o crtfilt crtfilt.o $(LIBS)
crtfilt.o: examples.h
nsprio: nsprio.o
$(CC) -o nsprio nsprio.o $(NSPRLIBS) $(LIBS)
nsprio.o: examples.h
runall: $(PROGS)
@for i in $(PROGS); do \
echo "-------------------------------------------------"; \
echo "Executing $$i example..."; \
./$$i; \
echo "$$i example done."; \
done
clean:
/bin/rm -f $(ALLPROGS) *.o a.out core

View File

@@ -0,0 +1,144 @@
Directory SDK Examples
----------------------
This directory contains some sample LDAP code to help you understand
how to use the Directory SDK. These examples are designed to work against
the sample data contained in the Netscape Directory Server 4.x
distribution. If you want to run these samples, you will need to have
a working LDAP server running, and the sample "airius.com" data
loaded.
NOTE: When linking to the LDAP API library, be aware that the different
versions of the Directory SDK have libraries with different names:
- In the SSL-enabled version of the Netscape Directory SDK for C,
the LDAP API library is named libldapssl41.so on Solaris, IRIX, and AIX,
and libldapssl41.sl on HP-UX. The import library for Microsoft
compilers is named nsldapssl32v41.lib, and the DLL is named
nsldapssl32v41.dll.
- In the non-SSL version of the Netscape Directory SDK for C,
the LDAP API library is named libldap41.so on Solaris, IRIX, and AIX,
and libldap41.sl on HP-UX. The import library for Microsoft
compilers is named nsldap32v41.lib, and the DLL is named
nsldap32v41.dll.
-------------------
Synchronous samples
-------------------
These samples use the synchronous LDAP calls. These calls are more
straightforward to use, and it's suggested you look at these examples
first. These calls will block the calling process until all results
have been returned, so they are probably not appropriate for use in a
client with a graphical user interface which relies an an event loop.
However, they're fine for command-line clients and CGI programs.
search.c
--------
Shows how to use ldap_search_s() to search for all entries which have
an attribute value which exactly matches what you're searching for. In
this example, all entries with the surname (last name) "Jensen" are
retrieved and displayed.
csearch.c
---------
Like search.c, but enables an in-memory cache.
ssnoauth.c
----------
Like search.c, but the search is done over SSL.
ssearch.c
---------
Like ssnoauth.c, but with certificate based authentication thrown in.
srvrsort.c
----------
Shows how to use server side sorting in conjunction with the
ldap_search_ext_s() function.
rdentry.c
---------
Shows how to use ldap_search_s() to retrieve a particular entry from the
directory. In this example, the entry "uid=bjensen, ou=People, o=airius.com"
is retrieved and displayed.
getattrs.c
----------
Just like read.c, but retrieves specific attributes from an entry.
compare.c
---------
Show how to use ldap_compare_s(), which allows you to test if a particular
value is contained in an attribute of an entry.
modattrs.c
----------
Shows how to use ldap_modify_s() to replace and add to values in an attribute.
modrdn.c
--------
Shows how to use ldap_modrdn2_s() to change the relative distinguished name
(rdn) of an entry.
getfilt.c
---------
Shows how to use the ldap_getfilter family of routines, which help generate
LDAP filters based on an arbitrary search string provided by a user.
crtfilt.c
---------
Shows how to use the ldap_create_filter() function to generate LDAP filters.
---------------------
Asynchronous examples
---------------------
These examples use the asynchronous LDAP calls. The general idea is that
you begin an operation, and then periodically poll to see if any results
have been returned.
asearch.c
---------
Initiates a search for entries, and polls for results, printing them as
they arrive.
nsprio.c
--------
Like asearch.c but using the prldap routines to incorporate NSPR.
add.c
------
Add an entry to the directory.
del.c
------
Delete an entry from the directory.
psearch.c
---------
Shows how to use the Persistent Search LDAPv3 protocol extension to
monitor a directory server for changes.
ppolicy.c
---------
Attempt to bind to the directory, and report back any password expiration
information received. This demonstrates how clients can process password
policy information that is optionally returned by Netscape Directory Server
3.0 and later.
-------------------
Additional examples
-------------------
The Macintosh or Windows versions of the Directory SDK also include
sample project files. A sample CodeWarrior project file is included
in the macintosh directory.
Sample Visual C++ makefiles for a Windows application (winldap) are
included in the windows directory. The Win32 version of the makefile
is named winldap.mak; the Win16 version of the makefile is named LDAP16.MAK.

View File

@@ -0,0 +1,156 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Add a new entry to the directory.
*
* Instead of calling the synchronous ldap_add_s() routine, we call
* the asynchronous routine ldap_add() and poll for results using
* ldap_result().
*
* Since it is an error to attempt to add an entry which already exists,
* you cannot run this example program twice in a row. You can use the
* adel.c example program to delete the entry which this example adds.
*
*/
#include "examples.h"
static void do_other_work();
unsigned long global_counter = 0;
static void free_mods( LDAPMod **mods );
#define NMODS 5
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result;
char *dn;
int i;
int rc;
int msgid;
int finished;
struct timeval zerotime;
LDAPMod **mods;
char *objectclass_values[] = { "top", "person", "organizationalPerson",
"inetOrgPerson", NULL };
char *cn_values[] = { "William B Jensen", "William Jensen", "Bill Jensen",
NULL };
char *sn_values[] = { "Jensen", NULL };
char *givenname_values[] = { "William", "Bill", NULL };
char *telephonenumber_values[] = { "+1 415 555 1212", NULL };
zerotime.tv_sec = zerotime.tv_usec = 0L;
/* Specify the DN we're adding */
dn = "cn=William B Jensen, " PEOPLE_BASE; /* see examples.h */
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as the Directory Manager */
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
/* Construct the array of values to add */
mods = ( LDAPMod ** ) malloc(( NMODS + 1 ) * sizeof( LDAPMod * ));
if ( mods == NULL ) {
fprintf( stderr, "Cannot allocate memory for mods array\n" );
}
for ( i = 0; i < NMODS; i++ ) {
if (( mods[ i ] = ( LDAPMod * ) malloc( sizeof( LDAPMod ))) == NULL ) {
fprintf( stderr, "Cannot allocate memory for mods element\n" );
exit( 1 );
}
}
mods[ 0 ]->mod_op = 0;
mods[ 0 ]->mod_type = "objectclass";
mods[ 0 ]->mod_values = objectclass_values;
mods[ 1 ]->mod_op = 0;
mods[ 1 ]->mod_type = "cn";
mods[ 1 ]->mod_values = cn_values;
mods[ 2 ]->mod_op = 0;
mods[ 2 ]->mod_type = "sn";
mods[ 2 ]->mod_values = sn_values;
mods[ 3 ]->mod_op = 0;
mods[ 3 ]->mod_type = "givenname";
mods[ 3 ]->mod_values = givenname_values;
mods[ 4 ]->mod_op = 0;
mods[ 4 ]->mod_type = "telephonenumber";
mods[ 4 ]->mod_values = telephonenumber_values;
mods[ 5 ] = NULL;
/* Initiate the add operation */
if (( msgid = ldap_add( ld, dn, mods )) < 0 ) {
ldap_perror( ld, "ldap_add" );
free_mods( mods );
return( 1 );
}
/* Poll for the result */
finished = 0;
while ( !finished ) {
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &result );
switch ( rc ) {
case -1:
/* some error occurred */
ldap_perror( ld, "ldap_result" );
free_mods( mods );
return( 1 );
case 0:
/* Timeout was exceeded. No entries are ready for retrieval */
break;
default:
/* Should be finished here */
finished = 1;
if (( rc = ldap_result2error( ld, result, 0 )) == LDAP_SUCCESS ) {
printf( "Entry added successfully. I counted to %ld "
"while waiting.\n", global_counter );
} else {
printf( "Error while adding entry: %s\n",
ldap_err2string( rc ));
}
ldap_msgfree( result );
}
do_other_work();
}
ldap_unbind( ld );
free_mods( mods );
return 0;
}
/*
* Free a mods array.
*/
static void
free_mods( LDAPMod **mods )
{
int i;
for ( i = 0; i < NMODS; i++ ) {
free( mods[ i ] );
}
free( mods );
}
/*
* Perform other work while polling for results. This doesn't do anything
* useful, but it could.
*/
static void
do_other_work()
{
global_counter++;
}

View File

@@ -0,0 +1,132 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Search the directory for all people whose surname (last name) is
* "Jensen". Since the "sn" attribute is a caseignorestring (cis), case
* is not significant when searching.
*
* Instead of calling the synchronous ldap_search_s() routine, we call
* the asynchronous routine ldap_search() and poll for results using
* ldap_result().
*
*/
#include "examples.h"
static void do_other_work();
unsigned long global_counter = 0;
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
int rc;
int finished;
int msgid;
int num_entries = 0;
struct timeval zerotime;
zerotime.tv_sec = zerotime.tv_usec = 0L;
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as nobody */
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
/* search for all entries with surname of Jensen */
if (( msgid = ldap_search( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE,
MY_FILTER, NULL, 0 )) < 0 ) {
ldap_perror( ld, "ldap_search" );
return( 1 );
}
/* Loop, polling for results until finished */
finished = 0;
while ( !finished ) {
/*
* Poll for results. We call ldap_result with the "all" argument
* set to LDAP_MSG_ONE. This causes ldap_result() to return exactly one
* entry if at least one entry is available. This allows us to
* display the entries as they are received.
*/
result = NULL;
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &result );
switch ( rc ) {
case -1:
/* some error occurred */
ldap_perror( ld, "ldap_result" );
return( 1 );
case 0:
/* Timeout was exceeded. No entries are ready for retrieval. */
if ( result != NULL ) {
ldap_msgfree( result );
}
break;
default:
/*
* Either an entry is ready for retrieval, or all entries have
* been retrieved.
*/
if (( e = ldap_first_entry( ld, result )) == NULL ) {
/* All done */
finished = 1;
if ( result != NULL ) {
ldap_msgfree( result );
}
continue;
}
/* for each entry print out name + all attrs and values */
num_entries++;
if (( dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if (( vals = ldap_get_values( ld, e, a )) != NULL ) {
for ( i = 0; vals[ i ] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[ i ] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
ldap_msgfree( result );
}
/* Do other work here while you are waiting... */
do_other_work();
}
/* All done. Print a summary. */
printf( "%d entries retrieved. I counted to %ld "
"while I was waiting.\n", num_entries,
global_counter );
ldap_unbind( ld );
return( 0 );
}
/*
* Perform other work while polling for results. This doesn't do anything
* useful, but it could.
*/
static void
do_other_work()
{
global_counter++;
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Use ldap_compare() to compare values agains values contained in entry
* ENTRYDN (defined in examples.h)
* We test to see if (1) the value "person" is one of the values in the
* objectclass attribute (it is), and if (2) the value "xyzzy" is in the
* objectlass attribute (it isn't, or at least, it shouldn't be).
*
*/
#include "examples.h"
int
main( int main, char **argv )
{
LDAP *ld;
int rc;
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as nobody */
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
/* compare the value "person" against the objectclass attribute */
rc = ldap_compare_s( ld, ENTRYDN, "objectclass", "person" );
switch ( rc ) {
case LDAP_COMPARE_TRUE:
printf( "The value \"person\" is contained in the objectclass "
"attribute.\n" );
break;
case LDAP_COMPARE_FALSE:
printf( "The value \"person\" is not contained in the objectclass "
"attribute.\n" );
break;
default:
ldap_perror( ld, "ldap_compare_s" );
}
/* compare the value "xyzzy" against the objectclass attribute */
rc = ldap_compare_s( ld, ENTRYDN, "objectclass", "xyzzy" );
switch ( rc ) {
case LDAP_COMPARE_TRUE:
printf( "The value \"xyzzy\" is contained in the objectclass "
"attribute.\n" );
break;
case LDAP_COMPARE_FALSE:
printf( "The value \"xyzzy\" is not contained in the objectclass "
"attribute.\n" );
break;
default:
ldap_perror( ld, "ldap_compare_s" );
}
ldap_unbind( ld );
return( 0 );
}

View File

@@ -0,0 +1,151 @@
/*
* Copyright (c) 1999. Netscape Communications Corporation. All
* rights reserved.
*
* Demonstrate use of the create filter function.
*/
#include "examples.h"
#define FILT_BUFSIZ 4096
struct filt_words {
char **f_words;
char *f_internal;
};
static int get_string_input( const char *prompt, const char *defaultval,
char *resultbuf );
static struct filt_words *val2words( const char *value, const char *delims );
static void freewords( struct filt_words *words );
int
main( int argc, char **argv )
{
int rc;
char patbuf[ FILT_BUFSIZ ];
char attrbuf[ FILT_BUFSIZ ], valuebuf[ FILT_BUFSIZ ];
char filtbuf[ FILT_BUFSIZ ];
struct filt_words *fwords;
patbuf[0] = attrbuf[0] = valuebuf[0] = '\0';
while ( 1 ) {
if ( get_string_input( "Enter a filter pattern: [%s] ", patbuf,
patbuf ) != 0 ) {
break;
}
if ( get_string_input( "Enter an attribute type: [%s] ", attrbuf,
attrbuf ) != 0 ) {
break;
}
if ( get_string_input( "Enter a value: [%s] ", valuebuf,
valuebuf ) != 0 ) {
break;
}
fwords = val2words( valuebuf, " " );
rc = ldap_create_filter( filtbuf, sizeof( filtbuf ), patbuf,
NULL, NULL, attrbuf, valuebuf, fwords->f_words );
freewords( fwords );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "ldap_create_filter: failed (%d - %s)\n", rc,
ldap_err2string( rc ));
} else {
printf( "Resulting filter: %s\n", filtbuf );
}
putchar( '\n' );
}
return( 0 );
}
/*
* Prompt the user for a string. The entered string is placed in resultbuf.
* If a zero-length string is entered, i.e., if they just hit return, the
* contents of defaultval are copied to resultbuf.
* Returns 0 if all goes well and -1 if error or end of file.
*/
static int
get_string_input( const char *prompt, const char *defaultval, char *resultbuf )
{
char inbuf[ FILT_BUFSIZ ];
inbuf[0] = '\0';
printf( prompt, defaultval );
if ( fgets( inbuf, sizeof( inbuf ), stdin ) == NULL ) {
return( -1 );
}
inbuf[ strlen( inbuf ) - 1 ] = '\0'; /* strip trailing newline */
if ( inbuf[ 0 ] == '\0' ) { /* use default value */
if ( defaultval != resultbuf ) {
strcpy( resultbuf, defaultval );
}
} else { /* use newly entered value */
strcpy( resultbuf, inbuf );
}
return( 0 );
}
static struct filt_words *
val2words( const char *value, const char *delims )
{
struct filt_words *fw;
char *word;
int i;
if (( fw = calloc( 1, sizeof( struct filt_words ))) == NULL ||
( fw->f_internal = strdup( value )) == NULL ) {
perror( "calloc OR strdup" );
exit( 1 );
}
word = strtok( fw->f_internal, delims );
i = 0;
while ( word != NULL ) {
if ( fw->f_words == NULL ) {
fw->f_words = (char **)malloc( (i + 2 ) * sizeof( char * ));
} else {
fw->f_words = (char **)realloc( fw->f_words,
(i + 2 ) * sizeof( char * ));
}
if ( fw->f_words == NULL ) {
perror( "malloc OR realloc" );
exit( 1 );
}
fw->f_words[ i ] = word;
fw->f_words[ ++i ] = NULL;
word = strtok( NULL, delims );
}
if ( i > 0 ) {
fw->f_words[ i ] = NULL;
}
return( fw );
}
static void
freewords( struct filt_words *words )
{
if ( words != NULL ) {
if ( words->f_words != NULL ) {
free( words->f_words );
}
if ( words->f_internal != NULL ) {
free( words->f_internal );
}
free( words );
}
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright (c) 2000. Netscape Communications Corporation. All
* rights reserved.
*
* Enable the in-memory cache and then search the directory 10 times
* for all people whose surname (last name) is "Jensen". Since the
* "sn" attribute is a caseignorestring (cis), case is not significant
* when searching.
*
*/
#include "examples.h"
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i, j;
LDAPMemCache *cacheHandle;
int memCache;
int mySearch();
int
main( int argc, char **argv )
{
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
memCache=ldap_memcache_init( 1800, 1024L * 1024, NULL, NULL, &cacheHandle );
switch ( memCache )
{
case LDAP_SUCCESS :
printf("LDAP_SUCCESS\n");
printf("LDAP_SUCCESS = %d\n", LDAP_SUCCESS);
printf("memCache = %d\n", memCache);
break;
case LDAP_PARAM_ERROR:
printf("LDAP_PARAM_ERROR\n");
break;
case LDAP_NO_MEMORY:
printf("LDAP_NO_MEMORY\n");
break;
case LDAP_SIZELIMIT_EXCEEDED:
printf("LDAP_SIZELIMITE_EXCEEDED\n");
break;
default :
printf("Unknown Error = %d\n", memCache);
break;
};
/* authenticate to the directory as nobody */
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
ldap_unbind( ld );
return( 1 );
}
ldap_memcache_set( ld, cacheHandle );
for ( j = 0; j < 10; ++j ) {
#ifdef _WINDOWS
Sleep( 1000 );
#else
sleep( 1 );
#endif
mySearch();
}
ldap_memcache_destroy( cacheHandle );
ldap_unbind( ld );
return 0;
}
int mySearch()
{
/* search for all entries with surname of Jensen */
if ( ldap_search_s( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE,
MY_FILTER, NULL, 0, &result ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search_s" );
if ( result == NULL ) {
ldap_unbind( ld );
return( 1 );
}
}
/* for each entry print out name + all attrs and values */
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[i] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
}
ldap_msgfree( result );
return( 0 );
}

View File

@@ -0,0 +1,93 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Delete an entry from the directory.
*
* Instead of calling the synchronous ldap_delete_s() routine, we call
* the asynchronous routine ldap_delete() and poll for results using
* ldap_result().
*
* Since it is an error to attempt to delete an entry which does not
* exist, you cannot run this example until you have added the entry
* with the aadd.c example program.
*
*/
#include "examples.h"
static void do_other_work();
unsigned long global_counter = 0;
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result;
char *dn;
int rc;
int msgid;
int finished;
struct timeval zerotime;
zerotime.tv_sec = zerotime.tv_usec = 0L;
/* Specify the DN we're deleting */
dn = "cn=William B Jensen, " PEOPLE_BASE; /* see examples.h */
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as the Directory Manager */
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
/* Initiate the delete operation */
if (( msgid = ldap_delete( ld, dn )) < 0 ) {
ldap_perror( ld, "ldap_delete" );
return( 1 );
}
/* Poll for the result */
finished = 0;
while ( !finished ) {
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &result );
switch ( rc ) {
case -1:
/* some error occurred */
ldap_perror( ld, "ldap_result" );
return( 1 );
case 0:
/* Timeout was exceeded. No entries are ready for retrieval */
break;
default:
/* Should be finished here */
finished = 1;
if (( rc = ldap_result2error( ld, result, 0 )) == LDAP_SUCCESS ) {
printf( "Entry deleted successfully. I counted to %ld "
"while waiting.\n", global_counter );
} else {
printf( "Error while deleting entry: %s\n",
ldap_err2string( rc ));
}
ldap_msgfree( result );
}
do_other_work();
}
ldap_unbind( ld );
return 0;
}
/*
* Perform other work while polling for results. This doesn't do anything
* useful, but it could.
*/
static void
do_other_work()
{
global_counter++;
}

View File

@@ -0,0 +1,88 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Common definitions for ldap example programs.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ldap.h>
/*
* Host name of LDAP server
*/
#define MY_HOST "localhost"
/*
* Port number where LDAP server is running
*/
#define MY_PORT LDAP_PORT
/*
* Port number where LDAPS server is running
*/
#define MY_SSL_PORT LDAPS_PORT
/*
* DN of directory manager entry. This entry should have write access to
* the entire directory.
*/
#define MGR_DN "cn=Directory Manager"
/*
* Password for manager DN.
*/
#define MGR_PW "secret99"
/*
* Subtree to search
*/
#define MY_SEARCHBASE "o=Airius.com"
/*
* Place where people entries are stored
*/
#define PEOPLE_BASE "ou=People, " MY_SEARCHBASE
/*
* DN of a user entry. This entry does not need any special access to the
* directory (it is not used to perform modifies, for example).
*/
#define USER_DN "uid=scarter, " PEOPLE_BASE
/*
* Password of the user entry.
*/
#define USER_PW "sprain"
/*
* Filter to use when searching. This one searches for all entries with the
* surname (last name) of "Jensen".
*/
#define MY_FILTER "(sn=Jensen)"
/*
* Entry to retrieve
*/
#define ENTRYDN "uid=bjensen, " PEOPLE_BASE
/*
* Password for Babs' entry
*/
#define ENTRYPW "hifalutin"
/*
* Name of file containing filters
*/
#define MY_FILTERFILE "xmplflt.conf"
/*
* Tag to use when retrieveing filters
*/
#define MY_FILTERTAG "ldap-example"

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Retrieve several attributes of a particular entry.
*/
#include "examples.h"
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
char **vals, *attrs[ 5 ];
int i;
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
attrs[ 0 ] = "cn"; /* Get canonical name(s) (full name) */
attrs[ 1 ] = "sn"; /* Get surname(s) (last name) */
attrs[ 2 ] = "mail"; /* Get email address(es) */
attrs[ 3 ] = "telephonenumber"; /* Get telephone number(s) */
attrs[ 4 ] = NULL;
if ( ldap_search_s( ld, ENTRYDN, LDAP_SCOPE_BASE,
"(objectclass=*)", attrs, 0, &result ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search_s" );
return( 1 );
}
/* print it out */
if (( e = ldap_first_entry( ld, result )) != NULL ) {
if (( vals = ldap_get_values( ld, e, "cn" )) != NULL ) {
printf( "Full name:\n" );
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "\t%s\n", vals[i] );
}
ldap_value_free( vals );
}
if (( vals = ldap_get_values( ld, e, "sn" )) != NULL ) {
printf( "Last name (surname):\n" );
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "\t%s\n", vals[i] );
}
ldap_value_free( vals );
}
if (( vals = ldap_get_values( ld, e, "mail" )) != NULL ) {
printf( "Email address:\n" );
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "\t%s\n", vals[i] );
}
ldap_value_free( vals );
}
if (( vals = ldap_get_values( ld, e, "telephonenumber" )) != NULL ) {
printf( "Telephone number:\n" );
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "\t%s\n", vals[i] );
}
ldap_value_free( vals );
}
}
ldap_msgfree( result );
ldap_unbind( ld );
return( 0 );
}

View File

@@ -0,0 +1,105 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Search for a user-provided string, using a filter configuration file.
* The filter config file controls which type of search is done, based
* on what the user types.
*/
#include "examples.h"
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
LDAPFiltDesc *ldfp;
LDAPFiltInfo *ldfi;
char buf[ 80 ];
int found;
/* Open the filter config file */
if (( ldfp = ldap_init_getfilter( MY_FILTERFILE )) == NULL ) {
fprintf( stderr, "Can't open filter file \"%s\"\n", MY_FILTERFILE );
return( 1 );
}
/* Read a string to search for */
printf( "Enter a string to search for: " );
gets( buf );
if ( strlen( buf ) == 0 ) {
fprintf( stderr, "usage: %s search-string\n", argv[ 0 ]);
return( 1 );
}
/* get a handle to an LDAP connection */
printf( "Initializing LDAP library... " ); fflush( stdout );
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
printf( "done.\n" ); fflush( stdout );
/* authenticate to the directory as nobody */
printf( "Binding to the directory... " ); fflush( stdout );
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
printf( "done.\n" ); fflush( stdout );
/* search for what the user typed */
found = 0;
for ( ldfi = ldap_getfirstfilter( ldfp, MY_FILTERTAG, buf );
ldfi != NULL; ldfi = ldap_getnextfilter( ldfp )) {
printf( "Filter: \"%s\"... ", ldfi->lfi_filter );
fflush( stdout );
if ( ldap_search_s( ld, MY_SEARCHBASE, ldfi->lfi_scope,
ldfi->lfi_filter, NULL, 0, &result ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search_s" );
return( 1 );
} else {
found = ldap_count_entries( ld, result );
printf( "done. Entries found: %d\n", found ); fflush( stdout );
if ( found > 0 ) {
/* Matching entries found - break */
break;
} else {
ldap_msgfree( result );
}
}
}
if ( found == 0 ) {
printf( "No matching entries found\n" );
} else {
printf( "Found %d %s match%s for \"%s\"\n\n", found,
ldfi->lfi_desc, found == 1 ? "" : "es", buf );
/* for each entry print out name + all attrs and values */
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if (( vals = ldap_get_values( ld, e, a )) != NULL ) {
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[i] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
}
ldap_msgfree( result );
}
ldap_getfilter_free( ldfp );
ldap_unbind( ld );
return( 0 );
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 1996-1998. Netscape Communications Corporation.
* All rights reserved.
*
* Modify an entry:
* - replace any existing "mail" attribute values with "babs@airius.com"
* - add a new value to the "description" attribute
*/
#include "examples.h"
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMod mod0, mod1, *mods[ 3 ];
char *vals0[ 2 ], *vals1[ 2 ], buf[ 128 ];
time_t now;
/* get an LDAP session handle and authenticate */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
/* construct the list of modifications to make */
mod0.mod_op = LDAP_MOD_REPLACE;
mod0.mod_type = "mail";
vals0[0] = "babs@airius.com";
vals0[1] = NULL;
mod0.mod_values = vals0;
mod1.mod_op = LDAP_MOD_ADD;
mod1.mod_type = "description";
time( &now );
sprintf( buf, "This entry was modified with the modattrs program on %s",
ctime( &now ));
/* Get rid of \n which ctime put on the end of the time string */
if ( buf[ strlen( buf ) - 1 ] == '\n' ) {
buf[ strlen( buf ) - 1 ] = '\0';
}
vals1[ 0 ] = buf;
vals1[ 1 ] = NULL;
mod1.mod_values = vals1;
mods[ 0 ] = &mod0;
mods[ 1 ] = &mod1;
mods[ 2 ] = NULL;
/* make the change and clean up after ourselves */
if ( ldap_modify_s( ld, ENTRYDN, mods ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_modify_s" );
return( 1 );
}
ldap_unbind( ld );
printf( "modification was successful\n" );
return( 0 );
}

View File

@@ -0,0 +1,148 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Modify the RDN (relative distinguished name) of an entry. In this
* example, we change the dn "cn=Jacques Smith, o=Airius.com"
* to "cn=Jacques M Smith, o=Airius.com".
*
* Since it is an error to either (1) attempt to modrdn an entry which
* does not exist, or (2) modrdn an entry where the destination name
* already exists, we take some steps, for this example, to make sure
* we'll succeed. We (1) add "cn=Jacques Smith" (if the entry exists,
* we just ignore the error, and (2) delete "cn=Jacques M Smith" (if the
* entry doesn't exist, we ignore the error).
*
* We pass 0 for the "deleteoldrdn" argument to ldap_modrdn2_s(). This
* means that after we change the RDN, the server will put the value
* "Jacques Smith" into the cn attribute of the new entry, in addition to
* "Jacques M Smith".
*/
#include "examples.h"
#define NMODS 4
unsigned long global_counter = 0;
static void free_mods( LDAPMod **mods );
int
main( int argc, char **argv )
{
LDAP *ld;
char *dn, *ndn, *nrdn;
int i;
int rc;
LDAPMod **mods;
/* Values we'll use in creating the entry */
char *objectclass_values[] = { "top", "person", "organizationalPerson",
"inetOrgPerson", NULL };
char *cn_values[] = { "Jacques Smith", NULL };
char *sn_values[] = { "Smith", NULL };
char *givenname_values[] = { "Jacques", NULL };
/* Specify the DN we're adding */
dn = "cn=Jacques Smith, " PEOPLE_BASE; /* see examples.h */
/* the destination DN */
ndn = "cn=Jacques M Smith, " PEOPLE_BASE; /* see examples.h */
/* the new RDN */
nrdn = "cn=Jacques M Smith";
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as the Directory Manager */
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
if (( mods = ( LDAPMod ** ) malloc(( NMODS + 1 ) * sizeof( LDAPMod *)))
== NULL ) {
fprintf( stderr, "Cannot allocate memory for mods array\n" );
return( 1 );
}
/* Construct the array of values to add */
for ( i = 0; i < NMODS; i++ ) {
if (( mods[ i ] = ( LDAPMod * ) malloc( sizeof( LDAPMod ))) == NULL ) {
fprintf( stderr, "Cannot allocate memory for mods element\n" );
return( 1 );
}
}
mods[ 0 ]->mod_op = 0;
mods[ 0 ]->mod_type = "objectclass";
mods[ 0 ]->mod_values = objectclass_values;
mods[ 1 ]->mod_op = 0;
mods[ 1 ]->mod_type = "cn";
mods[ 1 ]->mod_values = cn_values;
mods[ 2 ]->mod_op = 0;
mods[ 2 ]->mod_type = "sn";
mods[ 2 ]->mod_values = sn_values;
mods[ 3 ]->mod_op = 0;
mods[ 3 ]->mod_type = "givenname";
mods[ 3 ]->mod_values = givenname_values;
mods[ 4 ] = NULL;
/* Add the entry */
if (( rc = ldap_add_s( ld, dn, mods )) != LDAP_SUCCESS ) {
/* If entry exists already, fine. Ignore this error. */
if ( rc == LDAP_ALREADY_EXISTS ) {
printf( "Entry \"%s is already in the directory.\n", dn );
} else {
ldap_perror( ld, "ldap_add_s" );
free_mods( mods );
return( 1 );
}
} else {
printf( "Added entry \"%s\".\n", dn );
}
free_mods( mods );
/* Delete the destination entry, for this example */
if (( rc = ldap_delete_s( ld, ndn )) != LDAP_SUCCESS ) {
/* If entry does not exist, fine. Ignore this error. */
if ( rc == LDAP_NO_SUCH_OBJECT ) {
printf( "Entry \"%s\" is not in the directory. "
"No need to delete.\n", ndn );
} else {
ldap_perror( ld, "ldap_delete_s" );
return( 1 );
}
} else {
printf( "Deleted entry \"%s\".\n", ndn );
}
/* Do the modrdn operation */
if ( ldap_modrdn2_s( ld, dn, nrdn, 0 ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_modrdn2_s" );
return( 1 );
}
printf( "The modrdn operation was successful. Entry\n"
"\"%s\" has been changed to\n"
"\"%s\".\n", dn, ndn );
ldap_unbind( ld );
return 0;
}
/*
* Free a mods array.
*/
static void
free_mods( LDAPMod **mods )
{
int i;
for ( i = 0; i < NMODS; i++ ) {
free( mods[ i ] );
}
free( mods );
}

View File

@@ -0,0 +1,143 @@
/*
* Copyright (c) 2000. Netscape Communications Corporation. All
* rights reserved.
*
* A version of asearch.c that uses NSPR (Netscape Portable Runtime) I/O.
*
* Search the directory for all people whose surname (last name) is
* "Jensen". Since the "sn" attribute is a caseignorestring (cis), case
* is not significant when searching.
*
* Instead of calling the synchronous ldap_search_s() routine, we call
* the asynchronous routine ldap_search() and poll for results using
* ldap_result().
*
*/
#include "examples.h"
#include <nspr.h>
#include <ldappr.h>
static void do_other_work();
unsigned long global_counter = 0;
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
int rc;
int finished;
int msgid;
int num_entries = 0;
struct timeval zerotime;
zerotime.tv_sec = zerotime.tv_usec = 0L;
if ( prldap_install_routines( NULL, 1 /* shared */ ) != LDAP_SUCCESS ) {
ldap_perror( NULL, "prldap_install_routines" );
return( 1 );
}
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as nobody */
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
/* search for all entries with surname of Jensen */
if (( msgid = ldap_search( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE,
MY_FILTER, NULL, 0 )) < 0 ) {
ldap_perror( ld, "ldap_search" );
return( 1 );
}
/* Loop, polling for results until finished */
finished = 0;
while ( !finished ) {
/*
* Poll for results. We call ldap_result with the "all" argument
* set to LDAP_MSG_ONE. This causes ldap_result() to return exactly one
* entry if at least one entry is available. This allows us to
* display the entries as they are received.
*/
result = NULL;
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, &zerotime, &result );
switch ( rc ) {
case -1:
/* some error occurred */
ldap_perror( ld, "ldap_result" );
return( 1 );
case 0:
/* Timeout was exceeded. No entries are ready for retrieval. */
if ( result != NULL ) {
ldap_msgfree( result );
}
break;
default:
/*
* Either an entry is ready for retrieval, or all entries have
* been retrieved.
*/
if (( e = ldap_first_entry( ld, result )) == NULL ) {
/* All done */
finished = 1;
if ( result != NULL ) {
ldap_msgfree( result );
}
continue;
}
/* for each entry print out name + all attrs and values */
num_entries++;
if (( dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if (( vals = ldap_get_values( ld, e, a )) != NULL ) {
for ( i = 0; vals[ i ] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[ i ] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
ldap_msgfree( result );
}
/* Do other work here while you are waiting... */
do_other_work();
}
/* All done. Print a summary. */
printf( "%d entries retrieved. I counted to %ld "
"while I was waiting.\n", num_entries,
global_counter );
ldap_unbind( ld );
return( 0 );
}
/*
* Perform other work while polling for results. This doesn't do anything
* useful, but it could.
*/
static void
do_other_work()
{
global_counter++;
}

View File

@@ -0,0 +1,191 @@
/*
* Copyright (c) 1998. Netscape Communications Corporation. All
* rights reserved.
*
* Attempt to bind to the directory, and report back any password
* expiration information received.
*/
#include "examples.h"
#define NO_PASSWORD_CONTROLS 0
#define PASSWORD_EXPIRED -1
static void doUsage() {
printf( "Usage: ppolicy HOST PORT DN PASSWORD\n" );
}
static int
check_controls( LDAPControl **ctrls ) {
int i;
char buf[256];
int status = NO_PASSWORD_CONTROLS;
if ( ctrls == NULL ) {
return NO_PASSWORD_CONTROLS;
}
for ( i = 0; ctrls[ i ] != NULL; ++i ) {
memcpy( buf, ctrls[ i ]->ldctl_value.bv_val,
ctrls[ i ]->ldctl_value.bv_len );
buf[ctrls[ i ]->ldctl_value.bv_len] = 0;
if( !strcmp( LDAP_CONTROL_PWEXPIRED, ctrls[ i ]->ldctl_oid ) ) {
status = PASSWORD_EXPIRED;
} else if ( !strcmp( LDAP_CONTROL_PWEXPIRING,
ctrls[ i ]->ldctl_oid ) ) {
status = atoi( buf );
}
}
return status;
}
static void
process_other_errors( int lderr ) {
fprintf( stderr, "ldap_parse_result: %s",
ldap_err2string( lderr ));
if ( LDAP_CONNECT_ERROR == lderr ) {
perror( " - " );
} else {
fputc( '\n', stderr );
}
}
static void
process_other_messages( char *errmsg ) {
if ( errmsg != NULL ) {
if ( *errmsg != '\0' ) {
fprintf( stderr, "Additional info: %s\n",
errmsg );
}
ldap_memfree( errmsg );
}
}
int
main( int argc, char **argv ) {
LDAP *ld;
char *dn;
char *password;
char *host;
int port;
int rc = 0;
int version = LDAP_VERSION3;
int msgid;
LDAPMessage *result;
LDAPControl **ctrls;
int lderr;
int password_status = 0;
char *matcheddn, *errmsg, **refs;
if ( argc == 1 ) {
host = MY_HOST;
port = MY_PORT;
dn = USER_DN;
password = USER_PW;
} else if ( argc == 5 ) {
host = argv[1];
port = atoi( argv[2] );
dn = argv[3];
password = argv[4];
} else {
doUsage();
return( 1 );
}
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( host, port )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
if (ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version ) != 0) {
ldap_perror( ld, "ldap_set_option");
return ( 1 );
}
/* authenticate to the directory */
#ifdef SYNCHRONOUS_BIND
/* Synchronous bind */
ldap_simple_bind_s( ld, dn, password );
lderr = ldap_get_lderrno( ld, NULL, &errmsg );
if ( LDAP_SUCCESS == lderr ) {
printf( "Authentication successful\n" );
} else {
rc = -1;
if ( LDAP_INVALID_CREDENTIALS == lderr ) {
fprintf( stderr, "Invalid credentials\n" );
} else {
process_other_errors( lderr );
}
if ( errmsg != NULL ) {
if ( strstr( errmsg, "password expired" ) != NULL ) {
fprintf( stderr, "Password expired\n" );
} else {
fprintf( stderr, "Additional info: %s\n",
errmsg );
}
ldap_memfree( errmsg );
}
}
/* You can't get the controls with a synchronous bind, so we
can't report if the password is about to expire */
#else
/* Asynchronous bind */
if ( msgid = ldap_simple_bind( ld, dn, password ) < 0 ) {
ldap_perror( ld, "ldap_simple_bind" );
rc = -1;
} else {
rc = ldap_result( ld, LDAP_RES_ANY, LDAP_MSG_ONE,
(struct timeval *)NULL, &result );
if ( rc == LDAP_RES_BIND ) {
if ( ldap_parse_result( ld, result, &lderr, &matcheddn, &errmsg,
&refs, &ctrls, 0 ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_parse_result" );
} else {
if ( LDAP_SUCCESS == lderr ) {
printf( "Authentication successful\n" );
} else {
if ( LDAP_INVALID_CREDENTIALS == lderr ) {
fprintf( stderr, "Invalid credentials\n" );
} else {
process_other_errors( lderr );
}
if ( errmsg != NULL ) {
if ( strstr( errmsg, "password expired" ) != NULL ) {
fprintf( stderr, "Password expired\n" );
} else {
fprintf( stderr, "Additional info: %s\n",
errmsg );
}
ldap_memfree( errmsg );
}
}
password_status = check_controls( ctrls );
ldap_controls_free( ctrls );
if ( password_status == PASSWORD_EXPIRED ) {
fprintf( stderr,
"Password expired and must be reset\n" );
} else if ( password_status > 0 ) {
fprintf( stderr,
"Password will expire in %d seconds\n",
password_status );
}
rc = 0;
}
} else {
fprintf( stderr, "ldap_result returned %d\n", rc );
ldap_perror( ld, "ldap_result" );
rc = -1;
}
}
#endif
if ( LDAP_SUCCESS == lderr ) {
ldap_unbind( ld );
}
return rc;
}

View File

@@ -0,0 +1,193 @@
/*
* Copyright (c) 2000. Netscape Communications Corporation. All
* rights reserved.
*
* Use a Persistent Search to monitor the directory server for changes to
* all people entries whose surname (last name) is "Jensen".
*
*/
#include "examples.h"
static char *changetype_num2string( int chgtype );
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
int rc;
int finished;
int msgid;
int num_entries = 0;
int version = LDAP_VERSION3;
LDAPControl *ctrls[2], *psctrl, **ectrls;
/* arrange to use LDAP version 3 */
if ( ldap_set_option( NULL, LDAP_OPT_PROTOCOL_VERSION, &version ) != 0 ) {
perror( "ldap_set_option" );
return( 1 );
}
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as nobody */
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
ldap_unbind( ld );
return( 1 );
}
/* construct the Persistent Search control */
if ( ldap_create_persistentsearch_control( ld, LDAP_CHANGETYPE_ANY,
1 /* changesOnly */, 1 /* request entry change controls */,
1 /* critical */, &psctrl ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_create_persistentsearch_control" );
ldap_unbind( ld );
return( 1 );
}
ctrls[0] = psctrl;
ctrls[1] = NULL;
/* issue a persistent search for all entries with surname of Jensen */
if ( LDAP_SUCCESS != ldap_search_ext( ld, MY_SEARCHBASE,
LDAP_SCOPE_SUBTREE, MY_FILTER, NULL /* all attrs */,
0 /* get attrs and values */, ctrls, NULL /* no client ctrls */,
NULL /* no timeout */, 0 /* no sizelimit */, &msgid )) {
ldap_perror( ld, "ldap_search_ext" );
ldap_unbind( ld );
return( 1 );
}
ldap_control_free( psctrl ); /* no longer needed */
/*
* Loop, polling for results until finished.
* Since this is a persistent search, this loop won't end until the
* server shuts down or we lose the connection for some other reason.
* We could abandon the persistent search or close the connection of
* course, but we don't in this example.
*/
finished = 0;
while ( !finished ) {
/*
* Poll for results. We call ldap_result with the "all" argument
* set to LDAP_MSG_ONE. This causes ldap_result() to return exactly one
* entry if at least one entry is available. This allows us to
* display the entries as they are received.
*/
result = NULL;
rc = ldap_result( ld, msgid, LDAP_MSG_ONE, NULL /* no timeout */, &result );
switch ( rc ) {
case -1:
/* some error occurred */
ldap_perror( ld, "ldap_result" );
ldap_unbind( ld );
return( 1 );
case 0:
/* Timeout was exceeded. No entries are ready for retrieval. */
if ( result != NULL ) {
ldap_msgfree( result );
}
break;
default:
/*
* Either an entry is ready for retrieval, or all entries have
* been retrieved.
*/
if (( e = ldap_first_entry( ld, result )) == NULL ) {
/* All done */
finished = 1;
if ( result != NULL ) {
ldap_msgfree( result );
}
continue;
}
num_entries++;
/* for each entry print out name */
if (( dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
/* print entry change info. if it was returned */
if ( LDAP_SUCCESS == ldap_get_entry_controls( ld, e, &ectrls )) {
int chgtype, chgnumpresent;
long chgnum;
char *prevdn;
if ( LDAP_SUCCESS == ldap_parse_entrychange_control( ld,
ectrls, &chgtype, &prevdn, &chgnumpresent, &chgnum )) {
printf( "changeType: %s\n",
changetype_num2string( chgtype ));
if ( prevdn != NULL ) {
printf( "previousDN: %s\n", prevdn );
ldap_memfree( prevdn );
}
if ( chgnumpresent ) {
printf( "changeNumber: %d\n", chgnum );
}
ldap_controls_free( ectrls );
}
}
/* print out all attrs and values */
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if (( vals = ldap_get_values( ld, e, a )) != NULL ) {
for ( i = 0; vals[ i ] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[ i ] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
ldap_msgfree( result );
}
}
/* All done. Print a summary. */
printf( "%d entries retrieved.\n", num_entries );
ldap_unbind( ld );
return( 0 );
}
static char *
changetype_num2string( int chgtype )
{
static char buf[ 25 ];
char *s;
switch( chgtype ) {
case LDAP_CHANGETYPE_ADD:
s = "add";
break;
case LDAP_CHANGETYPE_DELETE:
s = "delete";
break;
case LDAP_CHANGETYPE_MODIFY:
s = "modify";
break;
case LDAP_CHANGETYPE_MODDN:
s = "moddn";
break;
default:
sprintf( s, "unknown (%d)", chgtype );
}
return( s );
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Search the directory for the specific entry ENTRYDN (defined in examples.h)
* Retrieve all attributes from the entry.
*
*/
#include "examples.h"
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as nobody */
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
return( 1 );
}
/* search for Babs' entry */
if ( ldap_search_s( ld, ENTRYDN, LDAP_SCOPE_SUBTREE,
"(objectclass=*)", NULL, 0, &result ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search_s" );
return( 1 );
}
/* for each entry print out name + all attrs and values */
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[i] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
}
ldap_msgfree( result );
ldap_unbind( ld );
return( 0 );
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright (c) 1996. Netscape Communications Corporation. All
* rights reserved.
*
* Search the directory for all people whose surname (last name) is
* "Jensen". Since the "sn" attribute is a caseignorestring (cis), case
* is not significant when searching.
*
*/
#include "examples.h"
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
/* get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT )) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* authenticate to the directory as nobody */
if ( ldap_simple_bind_s( ld, NULL, NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
ldap_unbind( ld );
return( 1 );
}
/* search for all entries with surname of Jensen */
if ( ldap_search_s( ld, MY_SEARCHBASE, LDAP_SCOPE_SUBTREE,
MY_FILTER, NULL, 0, &result ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search_s" );
if ( result == NULL ) {
ldap_unbind( ld );
return( 1 );
}
}
/* for each entry print out name + all attrs and values */
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[i] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
}
ldap_msgfree( result );
ldap_unbind( ld );
return( 0 );
}

View File

@@ -0,0 +1,145 @@
/*
* Copyright (c) 1999. Netscape Communications Corporation. All
* rights reserved.
*
* Search the directory for all people. Ask the server to sort the entries
* first by sn (last name) and then in reverse order by givenname (first name).
*/
#include "examples.h"
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
char *attrfail, *matched = NULL, *errmsg = NULL;
char **vals, **referrals;
int rc, parse_rc, version;
unsigned long sortrc;
LDAPControl *sortctrl = NULL;
LDAPControl *requestctrls[ 2 ];
LDAPControl **resultctrls = NULL;
LDAPsortkey **sortkeylist;
/* Arrange for all connections to use LDAPv3 */
version = LDAP_VERSION3;
if ( ldap_set_option( NULL, LDAP_OPT_PROTOCOL_VERSION, &version )
!= 0 ) {
fprintf( stderr,
"ldap_set_option protocol version to %d failed\n",
version );
return( 1 );
}
/* Get a handle to an LDAP connection */
if ( (ld = ldap_init( MY_HOST, MY_PORT ) ) == NULL ) {
perror( "ldap_init" );
return( 1 );
}
/* Authenticate as Directory Manager */
if ( ldap_simple_bind_s( ld, MGR_DN, MGR_PW ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_simple_bind_s" );
ldap_unbind( ld );
return( 1 );
}
/*
* Create a sort key list that specifies the sort order of the results.
* Sort the results by last name first, then by first name.
*/
ldap_create_sort_keylist( &sortkeylist, "description -givenname" );
/* Create the sort control. */
rc = ldap_create_sort_control( ld, sortkeylist, 1, &sortctrl );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "ldap_create_sort_control: %s\n",
ldap_err2string( rc ) );
ldap_unbind( ld );
return( 1 );
}
requestctrls[ 0 ] = sortctrl;
requestctrls[ 1 ] = NULL;
/* Search for all entries in Sunnyvale */
rc = ldap_search_ext_s( ld, "o=Airius.com", LDAP_SCOPE_SUBTREE,
"(objectclass=person)", NULL, 0, requestctrls, NULL, NULL, 0,
&result );
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "ldap_search_ext_s: %s\n",
ldap_err2string( rc ) );
ldap_unbind( ld );
return( 1 );
}
parse_rc = ldap_parse_result( ld, result, &rc, &matched, &errmsg,
&referrals, &resultctrls, 0 );
if ( parse_rc != LDAP_SUCCESS ) {
fprintf( stderr, "ldap_parse_result: %s\n",
ldap_err2string( parse_rc ) );
ldap_unbind( ld );
return( 1 );
}
if ( rc != LDAP_SUCCESS ) {
fprintf( stderr, "ldap_search_ext_s: %s\n",
ldap_err2string( rc ) );
if ( errmsg != NULL && *errmsg != '\0' ) {
fprintf( stderr, "%s\n", errmsg );
}
ldap_unbind( ld );
return( 1 );
}
parse_rc = ldap_parse_sort_control( ld, resultctrls, &sortrc,
&attrfail );
if ( parse_rc != LDAP_SUCCESS ) {
fprintf( stderr, "ldap_parse_sort_control: %s\n",
ldap_err2string( parse_rc ) );
ldap_unbind( ld );
return( 1 );
}
if ( sortrc != LDAP_SUCCESS ) {
fprintf( stderr, "Sort error: %s\n", ldap_err2string( sortrc ));
if ( attrfail != NULL && *attrfail != '\0' ) {
fprintf( stderr, "Bad attribute: %s\n", attrfail);
}
ldap_unbind( ld );
return( 1 );
}
/* for each entry print out name + all attrs and values */
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
if ((vals = ldap_get_values( ld, e, "sn")) != NULL ) {
if ( vals[0] != NULL ) {
printf( "%s", vals[0] );
}
ldap_value_free( vals );
}
if ((vals = ldap_get_values( ld, e, "givenname")) != NULL ) {
if ( vals[0] != NULL ) {
printf( "\t%s", vals[0] );
}
ldap_value_free( vals );
}
putchar( '\n' );
}
ldap_msgfree( result );
ldap_free_sort_keylist( sortkeylist );
ldap_control_free( sortctrl );
ldap_controls_free( resultctrls );
ldap_unbind( ld );
return( 0 );
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 2000. Netscape Communications Corporation. All
* rights reserved.
*
* Use an SSL connection to search the directory for all people whose
* surname (last name) is "Jensen". Since the "sn" attribute is a
* caseignorestring (cis), case is not significant when searching.
*
* Authenticate using a client certificate.
*
*/
#include "examples.h"
#include "ldap_ssl.h"
#define MY_CERTDB "/usr/netscape4/alias/client-cert.db"
#define MY_KEYDB "/usr/netscape4/alias/client-key.db"
#define MY_KEYNICKNAME "Server-Key"
#define MY_CERTNICKNAME "Server-Cert"
#define MY_KEYPASSWD "secret"
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
/* Initialize the client */
if ( ldapssl_clientauth_init( MY_CERTDB, NULL, 1 /* need key db */,
MY_KEYDB, NULL ) < 0 ) {
perror( "ldapssl_clientauth_init" );
return( 1 );
}
/* get a handle to an LDAP connection */
if ( (ld = ldapssl_init( MY_HOST, MY_SSL_PORT, 1 )) == NULL ) {
perror( "ldapssl_init" );
return( 1 );
}
/* use LDAPv3 */
i = LDAP_VERSION3;
if ( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &i ) < 0 ) {
ldap_perror( ld, "ldap_set_option LDAPv3" );
ldap_unbind( ld );
return( 1 );
}
/* enable certificate-based client authentication. */
if ( ldapssl_enable_clientauth( ld, MY_KEYNICKNAME, MY_KEYPASSWD,
MY_CERTNICKNAME ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldapssl_enable_clientauth" );
ldap_unbind( ld );
return( 1 );
}
if ( ldap_sasl_bind_s( ld, NULL, LDAP_SASL_EXTERNAL, NULL, NULL, NULL,
NULL ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_sasl_bind_s EXTERNAL" );
ldap_unbind( ld );
return( 1 );
}
/* search for all entries with surname of Jensen */
if ( ldap_search_s( ld, "o=Airius.com", LDAP_SCOPE_SUBTREE,
"(sn=jensen)", NULL, 0, &result ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search_s" );
if ( result == NULL ) {
ldap_unbind( ld );
return( 1 );
}
}
/* for each entry print out name + all attrs and values */
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[i] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
}
ldap_msgfree( result );
ldap_unbind( ld );
return( 0 );
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2000. Netscape Communications Corporation. All
* rights reserved.
*
* Use an SSL connection to search the directory for all people whose
* surname (last name) is "Jensen". Since the "sn" attribute is a
* caseignorestring (cis), case is not significant when searching.
*
*/
#include "examples.h"
#include "ldap_ssl.h"
#define MY_CERTDB "/usr/netscape4/alias/client-cert.db"
int
main( int argc, char **argv )
{
LDAP *ld;
LDAPMessage *result, *e;
BerElement *ber;
char *a, *dn;
char **vals;
int i;
/* Initialize the client */
if ( ldapssl_client_init( MY_CERTDB, NULL ) < 0 ) {
perror( "ldapssl_client_init" );
return( 1 );
}
/* get a handle to an LDAP connection */
if ( (ld = ldapssl_init( MY_HOST, MY_PORT, 1 )) == NULL ) {
perror( "ldapssl_init" );
return( 1 );
}
/* use LDAPv3 */
i = LDAP_VERSION3;
if ( ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &i ) < 0 ) {
ldap_perror( ld, "ldap_set_option LDAPv3" );
ldap_unbind( ld );
return( 1 );
}
/* search for all entries with surname of Jensen */
if ( ldap_search_s( ld, "o=Airius.com", LDAP_SCOPE_SUBTREE,
"(sn=jensen)", NULL, 0, &result ) != LDAP_SUCCESS ) {
ldap_perror( ld, "ldap_search_s" );
if ( result == NULL ) {
ldap_unbind( ld );
return( 1 );
}
}
/* for each entry print out name + all attrs and values */
for ( e = ldap_first_entry( ld, result ); e != NULL;
e = ldap_next_entry( ld, e ) ) {
if ( (dn = ldap_get_dn( ld, e )) != NULL ) {
printf( "dn: %s\n", dn );
ldap_memfree( dn );
}
for ( a = ldap_first_attribute( ld, e, &ber );
a != NULL; a = ldap_next_attribute( ld, e, ber ) ) {
if ((vals = ldap_get_values( ld, e, a)) != NULL ) {
for ( i = 0; vals[i] != NULL; i++ ) {
printf( "%s: %s\n", a, vals[i] );
}
ldap_value_free( vals );
}
ldap_memfree( a );
}
if ( ber != NULL ) {
ber_free( ber, 0 );
}
printf( "\n" );
}
ldap_msgfree( result );
ldap_unbind( ld );
return( 0 );
}

View File

@@ -0,0 +1,124 @@
#
# Copyright (c) 1996-1998. Netscape Communications Corporation. All
# rights reserved.
#
#
# Win32 GNU Makefile for Directory SDK examples
#
# build all the examples by typing: gmake -f win32.mak
#
###############################################################################
# Note that the LDAP API library has different names for the SSL-enabled
# and non-SSL versions of the Directory SDK for C:
#
# o In the SSL-enabled version, the import library for Microsoft
# compilers is named nsldapssl32v41.lib, and the DLL is named
# nsldapssl32v41.dll.
#
# o In the non-SSL version, the import library for Microsoft
# compilers is named nsldap32v41.lib, and the DLL is named
# nsldap32v41.dll.
#
# Remove the comment character in front of the definition of
# LDAPLIB that matches the name of the LDAP API library for the
# version you've downloaded.
#
# For Win32 (NT)
LDAPLIB=nsldap32v41
#LDAPLIB=nsldapssl32v41
NSPRLIB=libnspr3
EXTRACFLAGS=-nologo -W3 -GT -GX -D_X86_ -Dx386 -DWIN32 -D_WINDOWS -c
EXTRALDFLAGS=/NOLOGO /PDB:NONE /DEBUGTYPE:BOTH /SUBSYSTEM:console
###############################################################################
# You should not need to change anything below here....
INCDIR=../include
LIBDIR=../lib
NSPRINCDIR=../include
NSPRLIBDIR=../lib
SYSLIBS=wsock32.lib kernel32.lib user32.lib shell32.lib
LIBS=$(LIBDIR)/$(LDAPLIB).lib $(NSPRLIBDIR)/$(NSPRLIB).lib
CC=cl
OPTFLAGS=-MD
CFLAGS=$(OPTFLAGS) $(EXTRACFLAGS) -I$(INCDIR) -I$(NSPRINCDIR)
LINK=link
LDFLAGS=$(EXTRALDFLAGS)
PROGS=search asearch csearch psearch rdentry getattrs srvrsort modattrs add del compare modrdn ppolicy getfilt crtfilt
EXES=$(addsuffix .exe,$(PROGS))
SSLPROGS=ssnoauth ssearch
SSLEXES=$(addsuffix .exe,$(SSLPROGS))
NSPRPROGS=nsprio
NSPREXES=$(addsuffix .exe,$(NSPRPROGS))
ALLEXES= $(EXES) $(SSLEXES) $(NSEXES)
standard: $(EXES)
ssl: $(SSLEXES)
nspr: $(NSPREXES)
all: $(ALLEXES)
search.obj: examples.h
csearch.obj: examples.h
psearch.obj: examples.h
ssearch.obj: examples.h
ssnoauth.obj: examples.h
rdentry.obj: examples.h
getattrs.obj: examples.h
srvrsort.obj: examples.h
modattrs.obj: examples.h
asearch.obj: examples.h
add.obj: examples.h
del.obj: examples.h
compare.obj: examples.h
modrdn.obj: examples.h
ppolicy.obj: examples.h
getfilt.obj: examples.h
crtfilt.obj: examples.h
nsprio.obj: examples.h
runall: $(EXES)
@for i in $(PROGS); do \
echo '-------------------------------------------------'; \
./$$i; \
done
clean:
rm -f $(ALLEXES) *.obj
%.obj : %.c
$(CC) $(CFLAGS) $< -Fo$@
%.exe : %.obj
$(LINK) -OUT:$@ $(LDFLAGS) $(SYSLIBS) $< $(LIBS)

View File

@@ -0,0 +1,46 @@
// ConnDlg.cpp : implementation file
//
#include "stdafx.h"
#include "winldap.h"
#include "ConnDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// ConnDlg dialog
ConnDlg::ConnDlg(CWnd* pParent /*=NULL*/)
: CDialog(ConnDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(ConnDlg)
m_dirHost = _T("");
m_dirPort = 0;
//}}AFX_DATA_INIT
}
void ConnDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ConnDlg)
DDX_Text(pDX, IDC_DIR_HOST, m_dirHost);
DDX_Text(pDX, IDC_DIR_PORT, m_dirPort);
DDV_MinMaxInt(pDX, m_dirPort, 1, 32000);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ConnDlg, CDialog)
//{{AFX_MSG_MAP(ConnDlg)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// ConnDlg message handlers

View File

@@ -0,0 +1,36 @@
// ConnDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// ConnDlg dialog
class ConnDlg : public CDialog
{
// Construction
public:
ConnDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(ConnDlg)
enum { IDD = IDD_CONNECT_DIALOG };
CString m_dirHost;
int m_dirPort;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(ConnDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(ConnDlg)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

View File

@@ -0,0 +1,8 @@
NAME LDAP16
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE MULTIPLE
HEAPSIZE 1024
EXPORTS
; ===List your explicitly exported functions here===

View File

@@ -0,0 +1,186 @@
# Microsoft Visual C++ generated build script - Do not modify
PROJ = LDAP16
DEBUG = 0
PROGTYPE = 0
CALLER =
ARGS =
DLLS =
D_RCDEFINES = -d_DEBUG
R_RCDEFINES = -dNDEBUG
ORIGIN = MSVC
ORIGIN_VER = 1.00
PROJPATH = C:\NETSCAPE\LDAPSDK\EXAMPLES\WINDOWS\WINLDAP\
USEMFC = 1
CC = cl
CPP = cl
CXX = cl
CCREATEPCHFLAG =
CPPCREATEPCHFLAG =
CUSEPCHFLAG =
CPPUSEPCHFLAG =
FIRSTC =
FIRSTCPP = CONNDLG.CPP
RC = rc
CFLAGS_D_WEXE = /nologo /G3 /W3 /Zi /AL /Od /D "_DEBUG" /D "_AFX_NO_AFXCMN_SUPPORT" /D "_WINDOWS" /FR /GA /Fd"LDAP16.PDB"
CFLAGS_R_WEXE = /nologo /W3 /AL /O1 /D "NDEBUG" /D "_AFX_NO_AFXCMN_SUPPORT" /D "_WINDOWS" /FR /GA
LFLAGS_D_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:10240 /ALIGN:16 /ONERROR:NOEXE /CO
LFLAGS_R_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:10240 /ALIGN:16 /ONERROR:NOEXE
LIBS_D_WEXE = nsldap.lib lafxcwd oldnames libw llibcew commdlg.lib shell.lib
LIBS_R_WEXE = nsldap.lib lafxcw oldnames libw llibcew commdlg.lib shell.lib
RCFLAGS = /nologo
RESFLAGS = /nologo
RUNFLAGS =
DEFFILE = LDAP16.DEF
OBJS_EXT =
LIBS_EXT =
!if "$(DEBUG)" == "1"
CFLAGS = $(CFLAGS_D_WEXE)
LFLAGS = $(LFLAGS_D_WEXE)
LIBS = $(LIBS_D_WEXE)
MAPFILE = nul
RCDEFINES = $(D_RCDEFINES)
!else
CFLAGS = $(CFLAGS_R_WEXE)
LFLAGS = $(LFLAGS_R_WEXE)
LIBS = $(LIBS_R_WEXE)
MAPFILE = nul
RCDEFINES = $(R_RCDEFINES)
!endif
!if [if exist MSVC.BND del MSVC.BND]
!endif
SBRS = CONNDLG.SBR \
LDAPDOC.SBR \
LDAPVIEW.SBR \
MAINFRM.SBR \
PROPDLG.SBR \
SRCHDLG.SBR \
STDAFX.SBR \
WINLDAP.SBR
CONNDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
c:\netscape\ldapsdk\examples\windows\winldap\conndlg.h
LDAPDOC_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h
LDAPVIEW_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
c:\netscape\ldapsdk\include\ldap.h \
c:\netscape\ldapsdk\include\lber.h \
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h \
c:\netscape\ldapsdk\examples\windows\winldap\ldapview.h \
c:\netscape\ldapsdk\examples\windows\winldap\propdlg.h
MAINFRM_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
c:\netscape\ldapsdk\include\ldap.h \
c:\netscape\ldapsdk\include\lber.h \
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
c:\netscape\ldapsdk\examples\windows\winldap\mainfrm.h
PROPDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
c:\netscape\ldapsdk\include\ldap.h \
c:\netscape\ldapsdk\include\lber.h \
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
c:\netscape\ldapsdk\examples\windows\winldap\propdlg.h
SRCHDLG_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
c:\netscape\ldapsdk\include\ldap.h \
c:\netscape\ldapsdk\include\lber.h \
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
c:\netscape\ldapsdk\examples\windows\winldap\srchdlg.h
STDAFX_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h
WINLDAP_DEP = c:\netscape\ldapsdk\examples\windows\winldap\stdafx.h \
c:\netscape\ldapsdk\include\ldap.h \
c:\netscape\ldapsdk\include\lber.h \
c:\netscape\ldapsdk\examples\windows\winldap\winldap.h \
c:\netscape\ldapsdk\examples\windows\winldap\mainfrm.h \
c:\netscape\ldapsdk\examples\windows\winldap\ldapdoc.h \
c:\netscape\ldapsdk\examples\windows\winldap\ldapview.h \
c:\netscape\ldapsdk\examples\windows\winldap\conndlg.h \
c:\netscape\ldapsdk\examples\windows\winldap\srchdlg.h
LDAP16_RCDEP = c:\netscape\ldapsdk\examples\windows\winldap\res\winldap.ico \
c:\netscape\ldapsdk\examples\windows\winldap\res\winldap.rc2
all: $(PROJ).EXE $(PROJ).BSC
CONNDLG.OBJ: CONNDLG.CPP $(CONNDLG_DEP)
$(CPP) $(CFLAGS) $(CPPCREATEPCHFLAG) /c CONNDLG.CPP
LDAPDOC.OBJ: LDAPDOC.CPP $(LDAPDOC_DEP)
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c LDAPDOC.CPP
LDAPVIEW.OBJ: LDAPVIEW.CPP $(LDAPVIEW_DEP)
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c LDAPVIEW.CPP
MAINFRM.OBJ: MAINFRM.CPP $(MAINFRM_DEP)
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c MAINFRM.CPP
PROPDLG.OBJ: PROPDLG.CPP $(PROPDLG_DEP)
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c PROPDLG.CPP
SRCHDLG.OBJ: SRCHDLG.CPP $(SRCHDLG_DEP)
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c SRCHDLG.CPP
STDAFX.OBJ: STDAFX.CPP $(STDAFX_DEP)
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c STDAFX.CPP
WINLDAP.OBJ: WINLDAP.CPP $(WINLDAP_DEP)
$(CPP) $(CFLAGS) $(CPPUSEPCHFLAG) /c WINLDAP.CPP
LDAP16.RES: LDAP16.RC $(LDAP16_RCDEP)
$(RC) $(RCFLAGS) $(RCDEFINES) -r LDAP16.RC
$(PROJ).EXE:: LDAP16.RES
$(PROJ).EXE:: CONNDLG.OBJ LDAPDOC.OBJ LDAPVIEW.OBJ MAINFRM.OBJ PROPDLG.OBJ SRCHDLG.OBJ \
STDAFX.OBJ WINLDAP.OBJ $(OBJS_EXT) $(DEFFILE)
echo >NUL @<<$(PROJ).CRF
STDAFX.OBJ +
CONNDLG.OBJ +
LDAPDOC.OBJ +
LDAPVIEW.OBJ +
MAINFRM.OBJ +
PROPDLG.OBJ +
SRCHDLG.OBJ +
WINLDAP.OBJ +
$(OBJS_EXT)
$(PROJ).EXE
$(MAPFILE)
C:\MSVC\LIB\+
C:\MSVC\MFC\LIB\+
..\..\..\lib\+
$(LIBS)
$(DEFFILE);
<<
link $(LFLAGS) @$(PROJ).CRF
$(RC) $(RESFLAGS) LDAP16.RES $@
@copy $(PROJ).CRF MSVC.BND
$(PROJ).EXE:: LDAP16.RES
if not exist MSVC.BND $(RC) $(RESFLAGS) LDAP16.RES $@
run: $(PROJ).EXE
$(PROJ) $(RUNFLAGS)
$(PROJ).BSC: $(SBRS)
bscmake @<<
/o$@ $(SBRS)
<<

View File

@@ -0,0 +1,241 @@
//Microsoft App Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////
//
// From TEXTINCLUDE 2
//
#include "afxres.h"
////////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
#ifdef APSTUDIO_INVOKED
////////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""res\\winldap.rc2"" // non-App Studio edited resources\r\n"
"\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"\0"
END
/////////////////////////////////////////////////////////////////////////
#endif // APSTUDIO_INVOKED
////////////////////////////////////////////////////////////////////////////////
//
// Icon
//
IDR_MAINFRAME ICON DISCARDABLE res\winldap.ico
////////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Connect...\tCtrl+N", ID_FILE_CONNECT
MENUITEM "&Disconnect\tCtrl+D", ID_FILE_DISCONNECT
MENUITEM "&Search...\tCtrl+S", ID_FILE_SEARCH
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_APP_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About Test16...", ID_APP_ABOUT
END
END
////////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE
BEGIN
"N", ID_FILE_NEW, VIRTKEY,CONTROL
"O", ID_FILE_OPEN, VIRTKEY,CONTROL
"S", ID_FILE_SAVE, VIRTKEY,CONTROL
"Z", ID_EDIT_UNDO, VIRTKEY,CONTROL
"X", ID_EDIT_CUT, VIRTKEY,CONTROL
"C", ID_EDIT_COPY, VIRTKEY,CONTROL
"V", ID_EDIT_PASTE, VIRTKEY,CONTROL
VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT
VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT
VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL
VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT
VK_F6, ID_NEXT_PANE, VIRTKEY
VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT
END
////////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 34, 22, 217, 55
CAPTION "About Test16"
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20
LTEXT "Test16 Application Version 1.0",IDC_STATIC,40,10,119,8
LTEXT "Copyright \251 1997",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,176,6,32,14,WS_GROUP
END
IDD_CONNECT_DIALOG DIALOG DISCARDABLE 0, 0, 186, 76
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Connect to Directory Server"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,35,55,50,14
PUSHBUTTON "Cancel",IDCANCEL,103,55,50,14
RTEXT "Host name:",IDC_STATIC,21,17,52,12
EDITTEXT IDC_DIR_PORT,79,33,92,14,ES_AUTOHSCROLL
RTEXT "Port number:",IDC_STATIC,28,36,45,12
EDITTEXT IDC_DIR_HOST,79,14,92,14,ES_AUTOHSCROLL
END
IDD_SEARCH_DIALOG DIALOG DISCARDABLE 0, 0, 186, 103
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Search parameters"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,39,82,50,14
PUSHBUTTON "Cancel",IDCANCEL,105,82,50,14
RTEXT "Directory base:",IDC_STATIC,7,16,54,12
EDITTEXT IDC_SEARCH_BASE,65,13,106,14,ES_AUTOHSCROLL
RTEXT "Search filter:",IDC_STATIC,10,34,51,12
EDITTEXT IDC_SEARCH_FILTER,65,31,105,14,ES_AUTOHSCROLL
CONTROL "Base",IDC_SCOPE_BASE,"Button",BS_AUTORADIOBUTTON,23,60,
32,10
CONTROL "One level",IDC_SCOPE_ONE,"Button",BS_AUTORADIOBUTTON,69,
60,46,10
CONTROL "Subtree",IDC_SCOPE_SUB,"Button",BS_AUTORADIOBUTTON,121,
60,41,10
GROUPBOX "Scope",IDC_STATIC,13,49,159,24
END
IDD_ENTRY_PROPERTIES DIALOG DISCARDABLE 0, 0, 273, 202
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Properties"
FONT 8, "MS Sans Serif"
BEGIN
END
////////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "winldap\n\nWinlda\n\n\nWinldap.Document\nWinlda Document"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "Test16 Windows Application"
AFX_IDS_IDLEMESSAGE "Ready"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_INDICATOR_EXT "EXT"
ID_INDICATOR_CAPS "CAP"
ID_INDICATOR_NUM "NUM"
ID_INDICATOR_SCRL "SCRL"
ID_INDICATOR_OVR "OVR"
ID_INDICATOR_REC "REC"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_NEW "Create a new document"
ID_FILE_OPEN "Open an existing document"
ID_FILE_CLOSE "Close the active document"
ID_FILE_SAVE "Save the active document"
ID_FILE_SAVE_AS "Save the active document with a new name"
ID_APP_ABOUT "Display program information, version number and copyright"
ID_APP_EXIT "Quit the application; prompts to save documents"
ID_FILE_MRU_FILE1 "Open this document"
ID_FILE_MRU_FILE2 "Open this document"
ID_FILE_MRU_FILE3 "Open this document"
ID_FILE_MRU_FILE4 "Open this document"
ID_NEXT_PANE "Switch to the next window pane"
ID_PREV_PANE "Switch back to the previous window pane"
ID_EDIT_CLEAR "Erase the selection"
ID_EDIT_CLEAR_ALL "Erase everything"
ID_EDIT_COPY "Copy the selection and put it on the Clipboard"
ID_EDIT_CUT "Cut the selection and put it on the Clipboard"
ID_EDIT_FIND "Find the specified text"
ID_EDIT_PASTE "Insert Clipboard contents"
ID_EDIT_REPEAT "Repeat the last action"
ID_EDIT_REPLACE "Replace specific text with different text"
ID_EDIT_SELECT_ALL "Select the entire document"
ID_EDIT_UNDO "Undo the last action"
ID_EDIT_REDO "Redo the previously undone action"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change the window size"
AFX_IDS_SCMOVE "Change the window position"
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
AFX_IDS_SCRESTORE "Restore the window to normal size"
AFX_IDS_SCTASKLIST "Activate Task List"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_CONNECT "Connect to Directory Server"
ID_FILE_DISCONNECT "Disconnect from Directory Server"
ID_FILE_SEARCH "Search in Directory"
END
#ifndef APSTUDIO_INVOKED
////////////////////////////////////////////////////////////////////////////////
//
// From TEXTINCLUDE 3
//
#include "res\winldap.rc2" // non-App Studio edited resources
#include "afxres.rc" // Standard components
////////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,76 @@
// LdapDoc.cpp : implementation of the LdapDoc class
//
#include "stdafx.h"
#include "winldap.h"
#include "LdapDoc.h"
#ifdef _DEBUG
#ifdef _WIN32
#define new DEBUG_NEW
#endif
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// LdapDoc
IMPLEMENT_DYNCREATE(LdapDoc, CDocument)
BEGIN_MESSAGE_MAP(LdapDoc, CDocument)
//{{AFX_MSG_MAP(LdapDoc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// LdapDoc construction/destruction
LdapDoc::LdapDoc()
{
}
LdapDoc::~LdapDoc()
{
}
BOOL LdapDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
SetTitle( "" );
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// LdapDoc serialization
void LdapDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
}
else
{
}
}
/////////////////////////////////////////////////////////////////////////////
// LdapDoc diagnostics
#ifdef _DEBUG
void LdapDoc::AssertValid() const
{
CDocument::AssertValid();
}
void LdapDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// LdapDoc commands

View File

@@ -0,0 +1,42 @@
// LdapDoc.h : interface of the LdapDoc class
//
/////////////////////////////////////////////////////////////////////////////
class LdapDoc : public CDocument
{
protected: // create from serialization only
LdapDoc();
DECLARE_DYNCREATE(LdapDoc)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(LdapDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~LdapDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(LdapDoc)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,190 @@
// LdapView.cpp : implementation of the LdapView class
//
#include "stdafx.h"
#include "ldap.h"
#include "winldap.h"
#include "LdapDoc.h"
#include "LdapView.h"
#include "PropDlg.h"
#ifdef _DEBUG
#ifdef _WIN32
#define new DEBUG_NEW
#endif
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// LdapView
IMPLEMENT_DYNCREATE(LdapView, CView)
BEGIN_MESSAGE_MAP(LdapView, CView)
//{{AFX_MSG_MAP(LdapView)
ON_WM_SIZE()
ON_LBN_DBLCLK(5000,OnListDoubleClick)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// LdapView construction/destruction
LdapView::LdapView()
{
}
LdapView::~LdapView()
{
}
BOOL LdapView::PreCreateWindow(CREATESTRUCT& cs)
{
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// LdapView drawing
void LdapView::OnDraw(CDC* pDC)
{
LdapDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}
void LdapView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// Create a list box the same size as the client area
CRect rect;
GetClientRect( &rect );
m_list.Create( WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_NOTIFY, rect, this, 5000 );
}
void LdapView::AddLine( LPCSTR line, const char *dn )
{
// Add a string to the list box
int ind = m_list.AddString( line );
if ( NULL != dn )
m_list.SetItemDataPtr( ind, (void *)strdup(dn) );
}
void LdapView::ClearLines()
{
// Remove all lines from the list box
int nCount = m_list.GetCount();
while ( nCount > 0 )
{
char *str = (char *)m_list.GetItemDataPtr( 0 );
if ( str )
free( str );
nCount = m_list.DeleteString( 0 );
}
}
/////////////////////////////////////////////////////////////////////////////
// LdapView diagnostics
#ifdef _DEBUG
void LdapView::AssertValid() const
{
CView::AssertValid();
}
void LdapView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
LdapDoc* LdapView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(LdapDoc)));
return (LdapDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// LdapView message handlers
void LdapView::OnSize(UINT nType, int cx, int cy)
{
// Make sure the list box is resized along with the View
CView::OnSize(nType, cx, cy);
if ( ::IsWindow( m_list.m_hWnd ) )
m_list.SetWindowPos( &wndTop, 0, 0, cx, cy, SWP_NOZORDER );
}
// Fetch all attributes of an entry, and display them in a dialog
void LdapView::showProperties( LDAP *ld, char *dn )
{
PropDlg dlg;
if ( ldap_search( ld, dn, LDAP_SCOPE_BASE, "objectclass=*",
NULL, FALSE ) == -1 )
{
AfxMessageBox( "Failed to start asynchronous search" );
return;
}
LDAPMessage *res;
int rc;
// Process results as they come in
while ( (rc = ldap_result( ld, LDAP_RES_ANY, 0, NULL, &res ))
== LDAP_RES_SEARCH_ENTRY )
{
LDAPMessage *e = ldap_first_entry( ld, res );
BerElement *ber;
// Loop over attributes in this entry
for ( char *a = ldap_first_attribute( ld, e, &ber ); a != NULL;
a = ldap_next_attribute( ld, e, ber ) )
{
struct berval **bvals;
if ( (bvals = ldap_get_values_len( ld, e, a )) != NULL )
{
dlg.AddLine( a );
// Loop over values for this attribute
for ( int i = 0; bvals[i] != NULL; i++ )
{
CString val;
val.Format( " %s", bvals[ i ]->bv_val );
dlg.AddLine( val );
}
ber_bvecfree( bvals );
}
}
if ( ber != NULL )
ber_free( ber, 0 );
ldap_msgfree( res );
}
if ( rc == -1 )
{
AfxMessageBox( "Error on ldap_result" );
return;
}
else if (( rc = ldap_result2error( ld, res, 0 )) != LDAP_SUCCESS )
{
char *errString = ldap_err2string( rc );
AfxMessageBox( errString );
}
ldap_msgfree( res );
// Set the title of the dialog to the distinguished name, and display it
dlg.SetTitle( dn );
dlg.DoModal();
}
// Catch double-clicks on the list box, and fetch properties for a dn
void LdapView::OnListDoubleClick()
{
int ind = m_list.GetCurSel();
if ( ind >= 0 )
{
char *dn = (char *)m_list.GetItemDataPtr( ind );
if ( NULL != dn )
{
LDAP *ld = ((LdapApp *)AfxGetApp())->GetConnection();
if ( NULL != ld )
showProperties( ld, dn );
}
}
}

View File

@@ -0,0 +1,60 @@
// LdapView.h : interface of the LdapView class
//
/////////////////////////////////////////////////////////////////////////////
class LdapView : public CView
{
protected: // create from serialization only
LdapView();
DECLARE_DYNCREATE(LdapView)
// Attributes
public:
LdapDoc* GetDocument();
private:
CListBox m_list;
// Operations
public:
void AddLine( LPCSTR line, const char *dn=NULL );
void ClearLines();
private:
void showProperties( LDAP *ld, char *dn );
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(LdapView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void OnInitialUpdate(); // called first time after construct
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~LdapView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(LdapView)
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnListDoubleClick();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in LdapView.cpp
inline LdapDoc* LdapView::GetDocument()
{ return (LdapDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,85 @@
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "winldap.h"
#include "MainFrm.h"
#ifdef _DEBUG
#ifdef _WIN32
#define new DEBUG_NEW
#endif
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
return CFrameWnd::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers

View File

@@ -0,0 +1,43 @@
// MainFrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
// Generated message map functions
protected:
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,78 @@
// PropDlg.cpp : implementation file
//
#include "stdafx.h"
#include "winldap.h"
#include "PropDlg.h"
#ifdef _DEBUG
#ifdef _WIN32
#define new DEBUG_NEW
#endif
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// PropDlg dialog
PropDlg::PropDlg(CWnd* pParent /*=NULL*/)
: CDialog(PropDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(PropDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void PropDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(PropDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(PropDlg, CDialog)
//{{AFX_MSG_MAP(PropDlg)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// PropDlg message handlers
void PropDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if ( ::IsWindow( m_list.m_hWnd ) )
m_list.SetWindowPos( &wndTop, 0, 0, cx, cy, SWP_NOZORDER );
}
BOOL PropDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if ( m_title.GetLength() > 0 )
SetWindowText( m_title );
CRect rect;
GetClientRect( &rect );
m_list.Create( WS_CHILD|WS_VISIBLE|WS_VSCROLL|LBS_NOTIFY, rect, this, 5000 );
POSITION pos;
// Iterate through the list in head-to-tail order.
for( pos = m_strings.GetHeadPosition(); pos != NULL; )
{
m_list.AddString( m_strings.GetNext( pos ) );
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void PropDlg::AddLine( const char *str )
{
m_strings.AddTail( str );
}

View File

@@ -0,0 +1,45 @@
// PropDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// PropDlg dialog
class PropDlg : public CDialog
{
// Construction
public:
PropDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(PropDlg)
enum { IDD = IDD_ENTRY_PROPERTIES };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA
void SetTitle( const char *str ) { m_title = str; }
private:
CListBox m_list;
CStringList m_strings;
CString m_title;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(PropDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
public:
void AddLine( const char *line );
protected:
// Generated message map functions
//{{AFX_MSG(PropDlg)
afx_msg void OnSize(UINT nType, int cx, int cy);
virtual BOOL OnInitDialog();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

View File

@@ -0,0 +1,32 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by winldap.rc
//
#define IDD_ABOUTBOX 100
#define IDR_MAINFRAME 128
#define IDR_WINLDATYPE 129
#define IDD_CONNECT_DIALOG 130
#define IDD_SEARCH_DIALOG 131
#define IDD_ENTRY_PROPERTIES 132
#define IDC_SEARCH_BASE 1000
#define IDC_DIR_PORT 1001
#define IDC_SEARCH_FILTER 1001
#define IDC_DIR_HOST 1002
#define IDC_SCOPE_BASE 1002
#define IDC_SCOPE_ONE 1003
#define IDC_SCOPE_SUB 1004
#define ID_FILE_CONNECT 32771
#define ID_FILE_DISCONNECT 32772
#define ID_FILE_SEARCH 32773
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_3D_CONTROLS 1
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32774
#define _APS_NEXT_CONTROL_VALUE 1003
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@@ -0,0 +1,89 @@
// SrchDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ldap.h"
#include "winldap.h"
#include "SrchDlg.h"
#ifdef _DEBUG
#ifdef _WIN32
#define new DEBUG_NEW
#endif
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// SearchDlg dialog
SearchDlg::SearchDlg(CWnd* pParent /*=NULL*/)
: CDialog(SearchDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(SearchDlg)
m_searchBase = _T("");
m_searchFilter = _T("");
//}}AFX_DATA_INIT
}
void SearchDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SearchDlg)
DDX_Text(pDX, IDC_SEARCH_BASE, m_searchBase);
DDX_Text(pDX, IDC_SEARCH_FILTER, m_searchFilter);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(SearchDlg, CDialog)
//{{AFX_MSG_MAP(SearchDlg)
ON_BN_CLICKED(IDC_SCOPE_BASE, OnScopeBase)
ON_BN_DOUBLECLICKED(IDC_SCOPE_BASE, OnScopeBase)
ON_BN_CLICKED(IDC_SCOPE_ONE, OnScopeOne)
ON_BN_DOUBLECLICKED(IDC_SCOPE_ONE, OnScopeOne)
ON_BN_CLICKED(IDC_SCOPE_SUB, OnScopeSub)
ON_BN_DOUBLECLICKED(IDC_SCOPE_SUB, OnScopeSub)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SearchDlg message handlers
BOOL SearchDlg::OnInitDialog()
{
CDialog::OnInitDialog();
switch( m_scope )
{
case LDAP_SCOPE_SUBTREE:
((CButton *)GetDlgItem( IDC_SCOPE_SUB ))->SetCheck( 1 );
break;
case LDAP_SCOPE_BASE:
((CButton *)GetDlgItem( IDC_SCOPE_BASE ))->SetCheck( 1 );
break;
case LDAP_SCOPE_ONELEVEL:
((CButton *)GetDlgItem( IDC_SCOPE_ONE ))->SetCheck( 1 );
break;
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void SearchDlg::OnScopeBase()
{
m_scope = LDAP_SCOPE_BASE;
}
void SearchDlg::OnScopeOne()
{
m_scope = LDAP_SCOPE_ONELEVEL;
}
void SearchDlg::OnScopeSub()
{
m_scope = LDAP_SCOPE_SUBTREE;
}

View File

@@ -0,0 +1,47 @@
// SrchDlg.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// SearchDlg dialog
class SearchDlg : public CDialog
{
// Construction
public:
SearchDlg(CWnd* pParent = NULL); // standard constructor
public:
void SetScope( int scope ) { m_scope = scope; }
int GetScope() { return m_scope; }
private:
int m_scope;
public:
// Dialog Data
//{{AFX_DATA(SearchDlg)
enum { IDD = IDD_SEARCH_DIALOG };
CString m_searchBase;
CString m_searchFilter;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(SearchDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(SearchDlg)
virtual BOOL OnInitDialog();
afx_msg void OnScopeBase();
afx_msg void OnScopeOne();
afx_msg void OnScopeSub();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

View File

@@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// winldap.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,18 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifdef _WIN32
#include <afxcview.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,13 @@
//
// WINLDAP.RC2 - resources Microsoft Visual C++ does not edit directly
//
#ifdef APSTUDIO_INVOKED
#error this file is not editable by Microsoft Visual C++
#endif //APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
// Add manually edited resources here...
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,298 @@
// winldap.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "ldap.h"
#include "winldap.h"
#include "MainFrm.h"
#include "LdapDoc.h"
#include "LdapView.h"
#include "ConnDlg.h"
#include "SrchDlg.h"
#ifdef _DEBUG
#ifdef _WIN32
#define new DEBUG_NEW
#endif
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// LdapApp
BEGIN_MESSAGE_MAP(LdapApp, CWinApp)
//{{AFX_MSG_MAP(LdapApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_FILE_CONNECT, OnFileConnect)
ON_UPDATE_COMMAND_UI(ID_FILE_CONNECT, OnUpdateFileConnect)
ON_COMMAND(ID_FILE_DISCONNECT, OnFileDisconnect)
ON_UPDATE_COMMAND_UI(ID_FILE_DISCONNECT, OnUpdateFileDisconnect)
ON_COMMAND(ID_FILE_SEARCH, OnFileSearch)
ON_UPDATE_COMMAND_UI(ID_FILE_SEARCH, OnUpdateFileSearch)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// LdapApp construction
LdapApp::LdapApp()
{
m_ld = NULL;
m_connected = FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// The one and only LdapApp object
LdapApp theApp;
/////////////////////////////////////////////////////////////////////////////
// LdapApp initialization
BOOL LdapApp::InitInstance()
{
// Standard initialization
#ifdef _WIN32
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
#endif
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register document templates
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(LdapDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(LdapView));
AddDocTemplate(pDocTemplate);
#ifdef _WIN32
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
#else
// create a new (empty) document
OnFileNew();
if (m_lpCmdLine[0] != '\0')
{
}
#endif
m_dirHost = GetProfileString( "Connection", "host", "localhost" );
m_dirPort = GetProfileInt( "Connection", "port", 389 );
m_searchBase = GetProfileString( "Search", "base", "o=airius.com" );
m_scope = GetProfileInt( "Search", "scope", LDAP_SCOPE_SUBTREE );
m_searchFilter = GetProfileString( "Search", "filter", "objectclass=*" );
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void LdapApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// LdapApp commands
// Initialize an anonymous connection to a Directory Server
void LdapApp::OnFileConnect()
{
ConnDlg dlg;
dlg.m_dirHost = m_dirHost;
dlg.m_dirPort = m_dirPort;
if ( IDOK == dlg.DoModal() )
{
m_dirHost = dlg.m_dirHost;
m_dirPort = dlg.m_dirPort;
m_ld = ldap_init( m_dirHost, m_dirPort );
if ( NULL != m_ld )
{
// Bind as anonymous
if ( ldap_bind_s( m_ld, "", "", LDAP_AUTH_SIMPLE )
!= LDAP_SUCCESS )
{
AfxMessageBox( "Error binding!" );
return;
}
}
else
{
AfxMessageBox( "Error connecting!" );
return;
}
m_connected = TRUE;
LdapView *view = (LdapView *)((CFrameWnd *)AfxGetMainWnd())->GetActiveView();
if ( view )
{
CString title;
title.Format( "Host %s, port %d", m_dirHost, m_dirPort );
view->GetDocument()->SetTitle( title );
}
}
}
void LdapApp::OnUpdateFileConnect(CCmdUI* pCmdUI)
{
pCmdUI->Enable( !IsConnected() );
}
// Disconnect (unbind from) a Directory Server
void LdapApp::OnFileDisconnect()
{
ldap_unbind( m_ld );
m_ld = NULL;
m_connected = FALSE;
LdapView *view = (LdapView *)((CFrameWnd *)AfxGetMainWnd())->GetActiveView();
if ( view )
{
view->GetDocument()->SetTitle( "" );
}
}
void LdapApp::OnUpdateFileDisconnect(CCmdUI* pCmdUI)
{
pCmdUI->Enable( IsConnected() );
}
// Search for and report distinguished names (no attributes)
void LdapApp::OnFileSearch()
{
SearchDlg dlg;
dlg.m_searchBase = m_searchBase;
dlg.SetScope( m_scope );
dlg.m_searchFilter = m_searchFilter;
// Get desired search parameters
if ( IDOK == dlg.DoModal() )
{
m_searchBase = dlg.m_searchBase;
m_searchFilter = dlg.m_searchFilter;
m_scope = dlg.GetScope();
// Clear the result list
LdapView *view = (LdapView *)((CFrameWnd *)AfxGetMainWnd())->GetActiveView();
if ( view )
view->ClearLines();
char *attrs[2];
// "dn" is a pseudo-attribute; it is always returned anyway, but not as
// an attribute
attrs[0] = "dn";
attrs[1] = NULL;
if ( ldap_search( m_ld, m_searchBase, m_scope, m_searchFilter,
attrs, FALSE ) == -1 )
{
AfxMessageBox( "Failed to start asynchronous search" );
return;
}
LDAPMessage *res;
int rc;
// Fetch all results as they become available
while ( (rc = ldap_result( m_ld, LDAP_RES_ANY, 0, NULL, &res ))
== LDAP_RES_SEARCH_ENTRY )
{
LDAPMessage *e = ldap_first_entry( m_ld, res );
// Get the distinguished name and show it
char *dn = ldap_get_dn( m_ld, e );
if ( view )
view->AddLine( dn, dn );
ldap_memfree( dn );
ldap_msgfree( res );
// Let the view be updated
#ifdef _WIN32
Sleep( 0 );
#else
Yield();
#endif
}
if ( rc == -1 )
{
AfxMessageBox( "Error on ldap_result" );
return;
}
else if (( rc = ldap_result2error( m_ld, res, 0 )) != LDAP_SUCCESS )
{
char *errString = ldap_err2string( rc );
AfxMessageBox( errString );
}
ldap_msgfree( res );
}
}
void LdapApp::OnUpdateFileSearch(CCmdUI* pCmdUI)
{
pCmdUI->Enable( IsConnected() );
}
int LdapApp::ExitInstance()
{
WriteProfileString( "Connection", "host", m_dirHost );
WriteProfileInt( "Connection", "port", m_dirPort );
WriteProfileString( "Search", "base", m_searchBase );
WriteProfileInt( "Search", "scope", m_scope );
WriteProfileString( "Search", "filter", m_searchFilter );
return CWinApp::ExitInstance();
}

View File

@@ -0,0 +1,61 @@
// winldap.h : main header file for the WINLDAP application
//
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
#ifndef _LDAP_H
struct LDAP;
#endif
/////////////////////////////////////////////////////////////////////////////
// LdapApp:
// See winldap.cpp for the implementation of this class
//
class LdapApp : public CWinApp
{
public:
LdapApp();
public:
BOOL IsConnected() { return m_connected; }
LDAP *GetConnection() { return m_ld; }
private:
BOOL m_connected;
CString m_dirHost;
int m_dirPort;
CString m_searchBase;
CString m_searchFilter;
int m_scope;
LDAP *m_ld;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(LdapApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(LdapApp)
afx_msg void OnAppAbout();
afx_msg void OnFileConnect();
afx_msg void OnUpdateFileConnect(CCmdUI* pCmdUI);
afx_msg void OnFileDisconnect();
afx_msg void OnUpdateFileDisconnect(CCmdUI* pCmdUI);
afx_msg void OnFileSearch();
afx_msg void OnUpdateFileSearch(CCmdUI* pCmdUI);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,404 @@
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
!IF "$(CFG)" == ""
CFG=winldap - Win32 Debug
!MESSAGE No configuration specified. Defaulting to winldap - Win32 Debug.
!ENDIF
!IF "$(CFG)" != "winldap - Win32 Release" && "$(CFG)" !=\
"winldap - Win32 Debug"
!MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE on this makefile
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "winldap.mak" CFG="winldap - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "winldap - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "winldap - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
!ERROR An invalid configuration is specified.
!ENDIF
!IF "$(OS)" == "Windows_NT"
NULL=
!ELSE
NULL=nul
!ENDIF
################################################################################
# Begin Project
# PROP Target_Last_Scanned "winldap - Win32 Debug"
MTL=mktyplib.exe
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "winldap - Win32 Release"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
OUTDIR=.\Release
INTDIR=.\Release
ALL : "$(OUTDIR)\winldap.exe"
CLEAN :
-@erase "$(INTDIR)\ConnDlg.obj"
-@erase "$(INTDIR)\LdapDoc.obj"
-@erase "$(INTDIR)\LdapView.obj"
-@erase "$(INTDIR)\MainFrm.obj"
-@erase "$(INTDIR)\PropDlg.obj"
-@erase "$(INTDIR)\SrchDlg.obj"
-@erase "$(INTDIR)\StdAfx.obj"
-@erase "$(INTDIR)\winldap.obj"
-@erase "$(INTDIR)\winldap.pch"
-@erase "$(INTDIR)\winldap.res"
-@erase "$(OUTDIR)\winldap.exe"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
"_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/winldap.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/"\
/c
CPP_OBJS=.\Release/
CPP_SBRS=.\.
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /win32
MTL_PROJ=/nologo /D "NDEBUG" /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/winldap.res" /d "NDEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/winldap.bsc"
BSC32_SBRS= \
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
# ADD LINK32 nsldapssl32v30.lib /nologo /subsystem:windows /machine:I386
LINK32_FLAGS=nsldapssl32v30.lib /nologo /subsystem:windows /incremental:no\
/pdb:"$(OUTDIR)/winldap.pdb" /machine:I386 /out:"$(OUTDIR)/winldap.exe"
LINK32_OBJS= \
"$(INTDIR)\ConnDlg.obj" \
"$(INTDIR)\LdapDoc.obj" \
"$(INTDIR)\LdapView.obj" \
"$(INTDIR)\MainFrm.obj" \
"$(INTDIR)\PropDlg.obj" \
"$(INTDIR)\SrchDlg.obj" \
"$(INTDIR)\StdAfx.obj" \
"$(INTDIR)\winldap.obj" \
"$(INTDIR)\winldap.res"
"$(OUTDIR)\winldap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ELSEIF "$(CFG)" == "winldap - Win32 Debug"
# PROP BASE Use_MFC 6
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 6
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Target_Dir ""
OUTDIR=.\Debug
INTDIR=.\Debug
ALL : "$(OUTDIR)\winldap.exe"
CLEAN :
-@erase "$(INTDIR)\ConnDlg.obj"
-@erase "$(INTDIR)\LdapDoc.obj"
-@erase "$(INTDIR)\LdapView.obj"
-@erase "$(INTDIR)\MainFrm.obj"
-@erase "$(INTDIR)\PropDlg.obj"
-@erase "$(INTDIR)\SrchDlg.obj"
-@erase "$(INTDIR)\StdAfx.obj"
-@erase "$(INTDIR)\vc40.idb"
-@erase "$(INTDIR)\vc40.pdb"
-@erase "$(INTDIR)\winldap.obj"
-@erase "$(INTDIR)\winldap.pch"
-@erase "$(INTDIR)\winldap.res"
-@erase "$(OUTDIR)\winldap.exe"
-@erase "$(OUTDIR)\winldap.ilk"
-@erase "$(OUTDIR)\winldap.pdb"
"$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
/D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/winldap.pch" /Yu"stdafx.h"\
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
CPP_OBJS=.\Debug/
CPP_SBRS=.\.
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /win32
MTL_PROJ=/nologo /D "_DEBUG" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/winldap.res" /d "_DEBUG" /d "_AFXDLL"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
BSC32_FLAGS=/nologo /o"$(OUTDIR)/winldap.bsc"
BSC32_SBRS= \
LINK32=link.exe
# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
# ADD LINK32 nsldapssl32v30.lib /nologo /subsystem:windows /debug /machine:I386
LINK32_FLAGS=nsldapssl32v30.lib /nologo /subsystem:windows /incremental:yes\
/pdb:"$(OUTDIR)/winldap.pdb" /debug /machine:I386 /out:"$(OUTDIR)/winldap.exe"
LINK32_OBJS= \
"$(INTDIR)\ConnDlg.obj" \
"$(INTDIR)\LdapDoc.obj" \
"$(INTDIR)\LdapView.obj" \
"$(INTDIR)\MainFrm.obj" \
"$(INTDIR)\PropDlg.obj" \
"$(INTDIR)\SrchDlg.obj" \
"$(INTDIR)\StdAfx.obj" \
"$(INTDIR)\winldap.obj" \
"$(INTDIR)\winldap.res"
"$(OUTDIR)\winldap.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS)
<<
!ENDIF
.c{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_OBJS)}.obj:
$(CPP) $(CPP_PROJ) $<
.c{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cpp{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
.cxx{$(CPP_SBRS)}.sbr:
$(CPP) $(CPP_PROJ) $<
################################################################################
# Begin Target
# Name "winldap - Win32 Release"
# Name "winldap - Win32 Debug"
!IF "$(CFG)" == "winldap - Win32 Release"
!ELSEIF "$(CFG)" == "winldap - Win32 Debug"
!ENDIF
################################################################################
# Begin Source File
SOURCE=.\winldap.cpp
DEP_CPP_WINLD=\
".\ConnDlg.h"\
".\LdapDoc.h"\
".\LdapView.h"\
".\MainFrm.h"\
".\SrchDlg.h"\
".\StdAfx.h"\
".\winldap.h"\
"d:\projects\ldapsdk\include\lber.h"\
{$(INCLUDE)}"\ldap.h"\
{$(INCLUDE)}"\sys\time.h"\
{$(INCLUDE)}"\sys\types.h"\
"$(INTDIR)\winldap.obj" : $(SOURCE) $(DEP_CPP_WINLD) "$(INTDIR)"\
"$(INTDIR)\winldap.pch"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\StdAfx.cpp
DEP_CPP_STDAF=\
".\StdAfx.h"\
!IF "$(CFG)" == "winldap - Win32 Release"
# ADD CPP /Yc"stdafx.h"
BuildCmds= \
$(CPP) /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
"_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/winldap.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/"\
/c $(SOURCE) \
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
"$(INTDIR)\winldap.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
!ELSEIF "$(CFG)" == "winldap - Win32 Debug"
# ADD CPP /Yc"stdafx.h"
BuildCmds= \
$(CPP) /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
/D "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/winldap.pch" /Yc"stdafx.h"\
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c $(SOURCE) \
"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
"$(INTDIR)\winldap.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
$(BuildCmds)
!ENDIF
# End Source File
################################################################################
# Begin Source File
SOURCE=.\MainFrm.cpp
DEP_CPP_MAINF=\
".\MainFrm.h"\
".\StdAfx.h"\
".\winldap.h"\
"$(INTDIR)\MainFrm.obj" : $(SOURCE) $(DEP_CPP_MAINF) "$(INTDIR)"\
"$(INTDIR)\winldap.pch"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\LdapDoc.cpp
DEP_CPP_LDAPD=\
".\LdapDoc.h"\
".\StdAfx.h"\
".\winldap.h"\
"$(INTDIR)\LdapDoc.obj" : $(SOURCE) $(DEP_CPP_LDAPD) "$(INTDIR)"\
"$(INTDIR)\winldap.pch"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\LdapView.cpp
DEP_CPP_LDAPV=\
".\LdapDoc.h"\
".\LdapView.h"\
".\PropDlg.h"\
".\StdAfx.h"\
".\winldap.h"\
"d:\projects\ldapsdk\include\lber.h"\
{$(INCLUDE)}"\ldap.h"\
{$(INCLUDE)}"\sys\time.h"\
{$(INCLUDE)}"\sys\types.h"\
"$(INTDIR)\LdapView.obj" : $(SOURCE) $(DEP_CPP_LDAPV) "$(INTDIR)"\
"$(INTDIR)\winldap.pch"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\winldap.rc
DEP_RSC_WINLDA=\
".\res\LdapDoc.ico"\
".\res\winldap.ico"\
".\res\winldap.rc2"\
"$(INTDIR)\winldap.res" : $(SOURCE) $(DEP_RSC_WINLDA) "$(INTDIR)"
$(RSC) $(RSC_PROJ) $(SOURCE)
# End Source File
################################################################################
# Begin Source File
SOURCE=.\ConnDlg.cpp
DEP_CPP_CONND=\
".\ConnDlg.h"\
".\StdAfx.h"\
".\winldap.h"\
"$(INTDIR)\ConnDlg.obj" : $(SOURCE) $(DEP_CPP_CONND) "$(INTDIR)"\
"$(INTDIR)\winldap.pch"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\SrchDlg.cpp
DEP_CPP_SRCHD=\
".\SrchDlg.h"\
".\StdAfx.h"\
".\winldap.h"\
"d:\projects\ldapsdk\include\lber.h"\
{$(INCLUDE)}"\ldap.h"\
{$(INCLUDE)}"\sys\time.h"\
{$(INCLUDE)}"\sys\types.h"\
"$(INTDIR)\SrchDlg.obj" : $(SOURCE) $(DEP_CPP_SRCHD) "$(INTDIR)"\
"$(INTDIR)\winldap.pch"
# End Source File
################################################################################
# Begin Source File
SOURCE=.\PropDlg.cpp
DEP_CPP_PROPD=\
".\PropDlg.h"\
".\StdAfx.h"\
".\winldap.h"\
"$(INTDIR)\PropDlg.obj" : $(SOURCE) $(DEP_CPP_PROPD) "$(INTDIR)"\
"$(INTDIR)\winldap.pch"
# End Source File
# End Target
# End Project
################################################################################

View File

@@ -0,0 +1,406 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE 9, 1\r\n"
"#pragma code_page(1252)\r\n"
"#endif\r\n"
"#include ""res\\winldap.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
"#include ""afxres.rc"" // Standard components\r\n"
"#endif\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDR_MAINFRAME ICON DISCARDABLE "res\\winldap.ico"
IDR_WINLDATYPE ICON DISCARDABLE "res\\LdapDoc.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDR_MAINFRAME MENU PRELOAD DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "&Connect...\tCtrl+N", ID_FILE_CONNECT
MENUITEM "&Disconnect\tCtrl+D", ID_FILE_DISCONNECT
MENUITEM "&Search...\tCtrl+S", ID_FILE_SEARCH
MENUITEM SEPARATOR
MENUITEM "E&xit", ID_APP_EXIT
END
POPUP "&View"
BEGIN
MENUITEM "&Toolbar", ID_VIEW_TOOLBAR
MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR
END
POPUP "&Help"
BEGIN
MENUITEM "&About winldap...", ID_APP_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDR_MAINFRAME ACCELERATORS PRELOAD MOVEABLE PURE
BEGIN
"N", ID_FILE_NEW, VIRTKEY, CONTROL
"O", ID_FILE_OPEN, VIRTKEY, CONTROL
"S", ID_FILE_SAVE, VIRTKEY, CONTROL
"Z", ID_EDIT_UNDO, VIRTKEY, CONTROL
"X", ID_EDIT_CUT, VIRTKEY, CONTROL
"C", ID_EDIT_COPY, VIRTKEY, CONTROL
"V", ID_EDIT_PASTE, VIRTKEY, CONTROL
VK_BACK, ID_EDIT_UNDO, VIRTKEY, ALT
VK_DELETE, ID_EDIT_CUT, VIRTKEY, SHIFT
VK_INSERT, ID_EDIT_COPY, VIRTKEY, CONTROL
VK_INSERT, ID_EDIT_PASTE, VIRTKEY, SHIFT
VK_F6, ID_NEXT_PANE, VIRTKEY
VK_F6, ID_PREV_PANE, VIRTKEY, SHIFT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "About winldap"
FONT 8, "MS Sans Serif"
BEGIN
ICON IDR_MAINFRAME,IDC_STATIC,11,17,21,20
LTEXT "WinLdap - sample LDAP client",IDC_STATIC,40,10,119,8,
SS_NOPREFIX
LTEXT "Copyright © 1997",IDC_STATIC,40,25,119,8
DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
END
IDD_CONNECT_DIALOG DIALOG DISCARDABLE 0, 0, 186, 76
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Connect to Directory Server"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,35,55,50,14
PUSHBUTTON "Cancel",IDCANCEL,103,55,50,14
RTEXT "Host name:",IDC_STATIC,21,17,52,12
EDITTEXT IDC_DIR_PORT,79,33,92,14,ES_AUTOHSCROLL
RTEXT "Port number:",IDC_STATIC,28,36,45,12
EDITTEXT IDC_DIR_HOST,79,14,92,14,ES_AUTOHSCROLL
END
IDD_SEARCH_DIALOG DIALOG DISCARDABLE 0, 0, 186, 103
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Search parameters"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,39,82,50,14
PUSHBUTTON "Cancel",IDCANCEL,105,82,50,14
RTEXT "Directory base:",IDC_STATIC,7,16,54,12
EDITTEXT IDC_SEARCH_BASE,65,13,106,14,ES_AUTOHSCROLL
RTEXT "Search filter:",IDC_STATIC,10,34,51,12
EDITTEXT IDC_SEARCH_FILTER,65,31,105,14,ES_AUTOHSCROLL
CONTROL "Base",IDC_SCOPE_BASE,"Button",BS_AUTORADIOBUTTON,23,60,
32,10
CONTROL "One level",IDC_SCOPE_ONE,"Button",BS_AUTORADIOBUTTON,69,
60,46,10
CONTROL "Subtree",IDC_SCOPE_SUB,"Button",BS_AUTORADIOBUTTON,121,
60,41,10
GROUPBOX "Scope",IDC_STATIC,13,49,159,24
END
IDD_ENTRY_PROPERTIES DIALOG DISCARDABLE 0, 0, 273, 202
STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Properties"
FONT 8, "MS Sans Serif"
BEGIN
END
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "WINLDAP MFC Application\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "WINLDAP\0"
VALUE "LegalCopyright", "Copyright © 1997\0"
VALUE "OriginalFilename", "WINLDAP.EXE\0"
VALUE "ProductName", "WINLDAP Application\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // !_MAC
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_ABOUTBOX, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 210
TOPMARGIN, 7
BOTTOMMARGIN, 48
END
IDD_CONNECT_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 69
END
IDD_SEARCH_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 179
TOPMARGIN, 7
BOTTOMMARGIN, 96
END
IDD_ENTRY_PROPERTIES, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 266
TOPMARGIN, 7
BOTTOMMARGIN, 195
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
IDR_MAINFRAME "winldap\n\nWinlda\n\n\nWinldap.Document\nWinlda Document"
END
STRINGTABLE PRELOAD DISCARDABLE
BEGIN
AFX_IDS_APP_TITLE "winldap"
AFX_IDS_IDLEMESSAGE "Ready"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_INDICATOR_EXT "EXT"
ID_INDICATOR_CAPS "CAP"
ID_INDICATOR_NUM "NUM"
ID_INDICATOR_SCRL "SCRL"
ID_INDICATOR_OVR "OVR"
ID_INDICATOR_REC "REC"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_NEW "Create a new document\nNew"
ID_FILE_OPEN "Open an existing document\nOpen"
ID_FILE_CLOSE "Close the active document\nClose"
ID_FILE_SAVE "Save the active document\nSave"
ID_FILE_SAVE_AS "Save the active document with a new name\nSave As"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_APP_ABOUT "Display program information, version number and copyright\nAbout"
ID_APP_EXIT "Quit the application; prompts to save documents\nExit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_MRU_FILE1 "Open this document"
ID_FILE_MRU_FILE2 "Open this document"
ID_FILE_MRU_FILE3 "Open this document"
ID_FILE_MRU_FILE4 "Open this document"
ID_FILE_MRU_FILE5 "Open this document"
ID_FILE_MRU_FILE6 "Open this document"
ID_FILE_MRU_FILE7 "Open this document"
ID_FILE_MRU_FILE8 "Open this document"
ID_FILE_MRU_FILE9 "Open this document"
ID_FILE_MRU_FILE10 "Open this document"
ID_FILE_MRU_FILE11 "Open this document"
ID_FILE_MRU_FILE12 "Open this document"
ID_FILE_MRU_FILE13 "Open this document"
ID_FILE_MRU_FILE14 "Open this document"
ID_FILE_MRU_FILE15 "Open this document"
ID_FILE_MRU_FILE16 "Open this document"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_NEXT_PANE "Switch to the next window pane\nNext Pane"
ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_WINDOW_SPLIT "Split the active window into panes\nSplit"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_EDIT_CLEAR "Erase the selection\nErase"
ID_EDIT_CLEAR_ALL "Erase everything\nErase All"
ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy"
ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut"
ID_EDIT_FIND "Find the specified text\nFind"
ID_EDIT_PASTE "Insert Clipboard contents\nPaste"
ID_EDIT_REPEAT "Repeat the last action\nRepeat"
ID_EDIT_REPLACE "Replace specific text with different text\nReplace"
ID_EDIT_SELECT_ALL "Select the entire document\nSelect All"
ID_EDIT_UNDO "Undo the last action\nUndo"
ID_EDIT_REDO "Redo the previously undone action\nRedo"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar"
ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCSIZE "Change the window size"
AFX_IDS_SCMOVE "Change the window position"
AFX_IDS_SCMINIMIZE "Reduce the window to an icon"
AFX_IDS_SCMAXIMIZE "Enlarge the window to full size"
AFX_IDS_SCNEXTWINDOW "Switch to the next document window"
AFX_IDS_SCPREVWINDOW "Switch to the previous document window"
AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents"
END
STRINGTABLE DISCARDABLE
BEGIN
AFX_IDS_SCRESTORE "Restore the window to normal size"
AFX_IDS_SCTASKLIST "Activate Task List"
END
STRINGTABLE DISCARDABLE
BEGIN
ID_FILE_CONNECT "Connect to Directory Server"
ID_FILE_DISCONNECT "Disconnect from Directory Server"
ID_FILE_SEARCH "Search in Directory"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE 9, 1
#pragma code_page(1252)
#endif
#include "res\winldap.rc2" // non-Microsoft Visual C++ edited resources
#include "afxres.rc" // Standard components
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,43 @@
# example ldap filter file
#
# lines like this that start with # or empty lines are ignored
#
# syntax:
#
# <tag>
# <pattern1> <delimiters> <filter1-1> <desc1-1> [<scope>]
# <filter1-2> <desc1-2> [<scope>]
#
# <pattern2> <delimiters> <filter2-1> <desc2-1> [<scope>] ...
#
# The "desc" should describe the filter and it should correctly complete
# both of the following phrases:
#
# One <desc> match was found for...
# Three <desc> matches were found for...
#
# The scope is optional, and should be one of:
# "base"
# "onelevel"
# "subtree"
# if it is included.
#
"ldap-example"
"=" " " "%v" "arbitrary filter"
"^[+]*[0-9][ 0-9-]*$" " " "(telephoneNumber=*%v)" "phone number"
"@" " " "(mail=%v)" "email address"
"(mail=%v*)" "start of email address"
"^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
".*[. _].$" ". _" "(cn=%v1-*)" "last initial"
"[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
"(|(sn~=%v1-)(cn~=%v1-))" "approximate"
".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact"
"(|(cn~=%v1)(sn~=%v1))" "approximate"

View File

@@ -0,0 +1,4 @@
disptmpl.h
lber.h
ldap.h
srchpref.h

View File

@@ -0,0 +1,52 @@
DEPTH = ../../../..
MOD_DEPTH = ../../../../nsprpub
NSPR_TREE = ../../../../nsprpub
XPDIST = ../../../../dist
CHMOD = chmod
RM = rm -f
SED = sed
HEADERS = \
disptmpl.h \
lber.h \
ldap.h \
srchpref.h \
$(NULL)
include $(NSPR_TREE)/config/rules.mk
GARBAGE += sdkver.h dirver.h
ETCDIR = $(DIST)/etc
INCLUDEDIR = $(XPDIST)/public/ldap
DIR_VERSION := 2.0
DIRSDK_VERSION := 1.0
ifeq ($(OS_ARCH), WINNT)
# Is this correct?
DIRVER_PATH = $(DEPTH)/netsite/ldap/build
else
DIRVER_PATH = $(DIST)/bin
endif
DIRVER_PROG = $(DIRVER_PATH)/dirver$(BIN_SUFFIX)
###########################################################################
all export:: sdkver.h dirver.h FORCE
$(INSTALL) $(INSTALLFLAGS) -m 644 $(HEADERS) $(INCLUDEDIR)
$(INSTALL) $(INSTALLFLAGS) -m 644 $(HEADERS) $(DIST)/include
sdkver.h: $(DIRVER_PROG)
@$< $(DIRSDK_VERSION) UseSystemDate $@
dirver.h: $(DIRVER_PROG)
@$< $(DIR_VERSION) UseSystemDate $@
install:: export
clean::
FORCE:

View File

@@ -0,0 +1,51 @@
DEPTH = ../../../..
srcdir = @srcdir@
ldaptopsrcdir = @top_srcdir@
CHMOD = chmod
RM = rm -f
SED = sed
HEADERS = \
disptmpl.h \
lber.h \
ldap.h \
srchpref.h \
$(NULL)
HEADERS := $(addprefix $(srcdir)/, $(HEADERS))
include ../build/autoconf.mk
include $(NSPR_TREE)/config/rules.mk
GARBAGE += sdkver.h dirver.h
ETCDIR = $(DIST)/etc
DIR_VERSION := 2.0
DIRSDK_VERSION := 1.0
ifeq ($(OS_ARCH), WINNT)
# Is this correct?
DIRVER_PATH = $(DEPTH)/netsite/ldap/build
else
DIRVER_PATH = $(DIST)/bin
endif
DIRVER_PROG = $(DIRVER_PATH)/dirver$(BIN_SUFFIX)
###########################################################################
all export:: sdkver.h dirver.h FORCE
$(INSTALL) $(INSTALLFLAGS) -m 644 $(HEADERS) $(DIST)/include
sdkver.h: $(DIRVER_PROG)
@$< $(DIRSDK_VERSION) UseSystemDate $@
dirver.h: $(DIRVER_PROG)
@$< $(DIR_VERSION) UseSystemDate $@
install:: export
clean::
FORCE:

View File

@@ -0,0 +1,62 @@
/* avl.h - avl tree definitions */
/*
* Copyright (c) 1993 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* 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.
*/
#ifndef _AVL
#define _AVL
/*
* this structure represents a generic avl tree node.
*/
typedef struct avlnode {
caddr_t avl_data;
signed char avl_bf;
struct avlnode *avl_left;
struct avlnode *avl_right;
} Avlnode;
#define NULLAVL ((Avlnode *) NULL)
/* balance factor values */
#define LH -1
#define EH 0
#define RH 1
/* avl routines */
#define avl_getone(x) (x == 0 ? 0 : (x)->avl_data)
#define avl_onenode(x) (x == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
extern int avl_insert();
extern caddr_t avl_delete();
extern caddr_t avl_find();
extern caddr_t avl_getfirst();
extern caddr_t avl_getnext();
extern int avl_dup_error();
extern int avl_apply();
extern int avl_free();
/* apply traversal types */
#define AVL_PREORDER 1
#define AVL_INORDER 2
#define AVL_POSTORDER 3
/* what apply returns if it ran out of nodes */
#define AVL_NOMORE -6
#ifndef _IFP
#define _IFP
typedef int (*IFP)();
#endif
caddr_t avl_find_lin( Avlnode *root, caddr_t data, IFP fcmp );
#endif /* _AVL */

View File

@@ -0,0 +1,2 @@
/* This file is no longer used */

View File

@@ -0,0 +1,364 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/*
* Copyright (c) 1993, 1994 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* 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.
*
* disptmpl.h: display template library defines
*/
#ifndef _DISPTMPL_H
#define _DISPTMPL_H
#ifdef __cplusplus
extern "C" {
#endif
/* calling conventions used by library */
#ifndef LDAP_CALL
#if defined( _WINDOWS ) || defined( _WIN32 )
#define LDAP_C __cdecl
#ifndef _WIN32
#define __stdcall _far _pascal
#define LDAP_CALLBACK _loadds
#else
#define LDAP_CALLBACK
#endif /* _WIN32 */
#define LDAP_PASCAL __stdcall
#define LDAP_CALL LDAP_PASCAL
#else /* _WINDOWS */
#define LDAP_C
#define LDAP_CALLBACK
#define LDAP_PASCAL
#define LDAP_CALL
#endif /* _WINDOWS */
#endif /* LDAP_CALL */
#define LDAP_TEMPLATE_VERSION 1
/*
* general types of items (confined to most significant byte)
*/
#define LDAP_SYN_TYPE_TEXT 0x01000000L
#define LDAP_SYN_TYPE_IMAGE 0x02000000L
#define LDAP_SYN_TYPE_BOOLEAN 0x04000000L
#define LDAP_SYN_TYPE_BUTTON 0x08000000L
#define LDAP_SYN_TYPE_ACTION 0x10000000L
/*
* syntax options (confined to second most significant byte)
*/
#define LDAP_SYN_OPT_DEFER 0x00010000L
/*
* display template item syntax ids (defined by common agreement)
* these are the valid values for the ti_syntaxid of the tmplitem
* struct (defined below). A general type is encoded in the
* most-significant 8 bits, and some options are encoded in the next
* 8 bits. The lower 16 bits are reserved for the distinct types.
*/
#define LDAP_SYN_CASEIGNORESTR ( 1 | LDAP_SYN_TYPE_TEXT )
#define LDAP_SYN_MULTILINESTR ( 2 | LDAP_SYN_TYPE_TEXT )
#define LDAP_SYN_DN ( 3 | LDAP_SYN_TYPE_TEXT )
#define LDAP_SYN_BOOLEAN ( 4 | LDAP_SYN_TYPE_BOOLEAN )
#define LDAP_SYN_JPEGIMAGE ( 5 | LDAP_SYN_TYPE_IMAGE )
#define LDAP_SYN_JPEGBUTTON ( 6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
#define LDAP_SYN_FAXIMAGE ( 7 | LDAP_SYN_TYPE_IMAGE )
#define LDAP_SYN_FAXBUTTON ( 8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
#define LDAP_SYN_AUDIOBUTTON ( 9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER )
#define LDAP_SYN_TIME ( 10 | LDAP_SYN_TYPE_TEXT )
#define LDAP_SYN_DATE ( 11 | LDAP_SYN_TYPE_TEXT )
#define LDAP_SYN_LABELEDURL ( 12 | LDAP_SYN_TYPE_TEXT )
#define LDAP_SYN_SEARCHACTION ( 13 | LDAP_SYN_TYPE_ACTION )
#define LDAP_SYN_LINKACTION ( 14 | LDAP_SYN_TYPE_ACTION )
#define LDAP_SYN_ADDDNACTION ( 15 | LDAP_SYN_TYPE_ACTION )
#define LDAP_SYN_VERIFYDNACTION ( 16 | LDAP_SYN_TYPE_ACTION )
#define LDAP_SYN_RFC822ADDR ( 17 | LDAP_SYN_TYPE_TEXT )
/*
* handy macros
*/
#define LDAP_GET_SYN_TYPE( syid ) ((syid) & 0xFF000000UL )
#define LDAP_GET_SYN_OPTIONS( syid ) ((syid) & 0x00FF0000UL )
/*
* display options for output routines (used by entry2text and friends)
*/
/*
* use calculated label width (based on length of longest label in
* template) instead of contant width
*/
#define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001L
#define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L
/*
* perform search actions (applies to ldap_entry2text_search only)
*/
#define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002L
/*
* include additional info. relevant to "non leaf" entries only
* used by ldap_entry2html and ldap_entry2html_search to include "Browse"
* and "Move Up" HREFs
*/
#define LDAP_DISP_OPT_NONLEAF 0x00000004L
/*
* display template item options (may not apply to all types)
* if this bit is set in ti_options, it applies.
*/
#define LDAP_DITEM_OPT_READONLY 0x00000001L
#define LDAP_DITEM_OPT_SORTVALUES 0x00000002L
#define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004L
#define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008L
#define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010L
#define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020L /* booleans only */
/*
* display template item structure
*/
struct ldap_tmplitem {
unsigned long ti_syntaxid;
unsigned long ti_options;
char *ti_attrname;
char *ti_label;
char **ti_args;
struct ldap_tmplitem *ti_next_in_row;
struct ldap_tmplitem *ti_next_in_col;
void *ti_appdata;
};
#define NULLTMPLITEM ((struct ldap_tmplitem *)0)
#define LDAP_SET_TMPLITEM_APPDATA( ti, datap ) \
(ti)->ti_appdata = (void *)(datap)
#define LDAP_GET_TMPLITEM_APPDATA( ti, type ) \
(type)((ti)->ti_appdata)
#define LDAP_IS_TMPLITEM_OPTION_SET( ti, option ) \
(((ti)->ti_options & option ) != 0 )
/*
* object class array structure
*/
struct ldap_oclist {
char **oc_objclasses;
struct ldap_oclist *oc_next;
};
#define NULLOCLIST ((struct ldap_oclist *)0)
/*
* add defaults list
*/
struct ldap_adddeflist {
int ad_source;
#define LDAP_ADSRC_CONSTANTVALUE 1
#define LDAP_ADSRC_ADDERSDN 2
char *ad_attrname;
char *ad_value;
struct ldap_adddeflist *ad_next;
};
#define NULLADLIST ((struct ldap_adddeflist *)0)
/*
* display template global options
* if this bit is set in dt_options, it applies.
*/
/*
* users should be allowed to try to add objects of these entries
*/
#define LDAP_DTMPL_OPT_ADDABLE 0x00000001L
/*
* users should be allowed to do "modify RDN" operation of these entries
*/
#define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L
/*
* this template is an alternate view, not a primary view
*/
#define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L
/*
* display template structure
*/
struct ldap_disptmpl {
char *dt_name;
char *dt_pluralname;
char *dt_iconname;
unsigned long dt_options;
char *dt_authattrname;
char *dt_defrdnattrname;
char *dt_defaddlocation;
struct ldap_oclist *dt_oclist;
struct ldap_adddeflist *dt_adddeflist;
struct ldap_tmplitem *dt_items;
void *dt_appdata;
struct ldap_disptmpl *dt_next;
};
#define NULLDISPTMPL ((struct ldap_disptmpl *)0)
#define LDAP_SET_DISPTMPL_APPDATA( dt, datap ) \
(dt)->dt_appdata = (void *)(datap)
#define LDAP_GET_DISPTMPL_APPDATA( dt, type ) \
(type)((dt)->dt_appdata)
#define LDAP_IS_DISPTMPL_OPTION_SET( dt, option ) \
(((dt)->dt_options & option ) != 0 )
#define LDAP_TMPL_ERR_VERSION 1
#define LDAP_TMPL_ERR_MEM 2
#define LDAP_TMPL_ERR_SYNTAX 3
#define LDAP_TMPL_ERR_FILE 4
/*
* buffer size needed for entry2text and vals2text
*/
#define LDAP_DTMPL_BUFSIZ 8192
typedef int (*writeptype)( void *writeparm, char *p, int len );
LDAP_API(int)
LDAP_CALL
ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp );
LDAP_API(int)
LDAP_CALL
ldap_init_templates_buf( char *buf, long buflen,
struct ldap_disptmpl **tmpllistp );
LDAP_API(void)
LDAP_CALL
ldap_free_templates( struct ldap_disptmpl *tmpllist );
LDAP_API(struct ldap_disptmpl *)
LDAP_CALL
ldap_first_disptmpl( struct ldap_disptmpl *tmpllist );
LDAP_API(struct ldap_disptmpl *)
LDAP_CALL
ldap_next_disptmpl( struct ldap_disptmpl *tmpllist,
struct ldap_disptmpl *tmpl );
LDAP_API(struct ldap_disptmpl *)
LDAP_CALL
ldap_name2template( char *name, struct ldap_disptmpl *tmpllist );
LDAP_API(struct ldap_disptmpl *)
LDAP_CALL
ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist );
LDAP_API(char **)
LDAP_CALL
ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, int exclude,
unsigned long syntaxmask );
LDAP_API(struct ldap_tmplitem *)
LDAP_CALL
ldap_first_tmplrow( struct ldap_disptmpl *tmpl );
LDAP_API(struct ldap_tmplitem *)
LDAP_CALL
ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
LDAP_API(struct ldap_tmplitem *)
LDAP_CALL
ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
LDAP_API(struct ldap_tmplitem *)
LDAP_CALL
ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
struct ldap_tmplitem *col );
LDAP_API(int)
LDAP_CALL
ldap_entry2text( LDAP *ld, char *buf, LDAPMessage *entry,
struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
writeptype writeproc, void *writeparm, char *eol, int rdncount,
unsigned long opts );
LDAP_API(int)
LDAP_CALL
ldap_vals2text( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
unsigned long syntaxid, writeptype writeproc, void *writeparm,
char *eol, int rdncount );
LDAP_API(int)
LDAP_CALL
ldap_entry2text_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
writeptype writeproc, void *writeparm, char *eol, int rdncount,
unsigned long opts );
LDAP_API(int)
LDAP_CALL
ldap_entry2html( LDAP *ld, char *buf, LDAPMessage *entry,
struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
writeptype writeproc, void *writeparm, char *eol, int rdncount,
unsigned long opts, char *urlprefix, char *base );
LDAP_API(int)
LDAP_CALL
ldap_vals2html( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
unsigned long syntaxid, writeptype writeproc, void *writeparm,
char *eol, int rdncount, char *urlprefix );
LDAP_API(int)
LDAP_CALL
ldap_entry2html_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
writeptype writeproc, void *writeparm, char *eol, int rdncount,
unsigned long opts, char *urlprefix );
LDAP_API(char *)
LDAP_CALL
ldap_tmplerr2string( int err );
#ifdef __cplusplus
}
#endif
#endif /* _DISPTMPL_H */

View File

@@ -0,0 +1,290 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/* lber.h - header file for ber_* functions */
#ifndef _LBER_H
#define _LBER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h> /* to pick up size_t typedef */
/*
* Note that LBER_ERROR and LBER_DEFAULT are values that can never appear
* as valid BER tags, and so it is safe to use them to report errors. In
* fact, any tag for which the following is true is invalid:
* (( tag & 0x00000080 ) != 0 ) && (( tag & 0xFFFFFF00 ) != 0 )
*/
#define LBER_ERROR 0xffffffffUL
#define LBER_DEFAULT 0xffffffffUL
#define LBER_END_OF_SEQORSET 0xfffffffeUL
/* BER classes and mask */
#define LBER_CLASS_UNIVERSAL 0x00
#define LBER_CLASS_APPLICATION 0x40
#define LBER_CLASS_CONTEXT 0x80
#define LBER_CLASS_PRIVATE 0xc0
#define LBER_CLASS_MASK 0xc0
/* BER encoding type and mask */
#define LBER_PRIMITIVE 0x00
#define LBER_CONSTRUCTED 0x20
#define LBER_ENCODING_MASK 0x20
#define LBER_BIG_TAG_MASK 0x1f
#define LBER_MORE_TAG_MASK 0x80
/* general BER types we know about */
#define LBER_BOOLEAN 0x01L
#define LBER_INTEGER 0x02L
#define LBER_BITSTRING 0x03L
#define LBER_OCTETSTRING 0x04L
#define LBER_NULL 0x05L
#define LBER_ENUMERATED 0x0aL
#define LBER_SEQUENCE 0x30L
#define LBER_SET 0x31L
/* BerElement set/get options */
#define LBER_OPT_REMAINING_BYTES 0x01
#define LBER_OPT_TOTAL_BYTES 0x02
#define LBER_OPT_USE_DER 0x04
#define LBER_OPT_TRANSLATE_STRINGS 0x08
#define LBER_OPT_BYTES_TO_WRITE 0x10
#define LBER_OPT_MEMALLOC_FN_PTRS 0x20
#define LBER_OPT_DEBUG_LEVEL 0x40
/*
* LBER_USE_DER is defined for compatibility with the C LDAP API RFC.
* In our implementation, we recognize it (instead of the numerically
* identical LBER_OPT_REMAINING_BYTES) in calls to ber_alloc_t() and
* ber_init_w_nullchar() only. Callers of ber_set_option() or
* ber_get_option() must use LBER_OPT_USE_DER instead. Sorry!
*/
#define LBER_USE_DER 0x01
/* Sockbuf set/get options */
#define LBER_SOCKBUF_OPT_TO_FILE 0x001
#define LBER_SOCKBUF_OPT_TO_FILE_ONLY 0x002
#define LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE 0x004
#define LBER_SOCKBUF_OPT_NO_READ_AHEAD 0x008
#define LBER_SOCKBUF_OPT_DESC 0x010
#define LBER_SOCKBUF_OPT_COPYDESC 0x020
#define LBER_SOCKBUF_OPT_READ_FN 0x040
#define LBER_SOCKBUF_OPT_WRITE_FN 0x080
#define LBER_SOCKBUF_OPT_EXT_IO_FNS 0x100
#define LBER_OPT_ON ((void *) 1)
#define LBER_OPT_OFF ((void *) 0)
typedef struct berval {
unsigned long bv_len;
char *bv_val;
} BerValue;
typedef struct berelement BerElement;
typedef struct sockbuf Sockbuf;
typedef int (*BERTranslateProc)( char **bufp, unsigned long *buflenp,
int free_input );
#ifndef macintosh
#if defined( _WINDOWS ) || defined( _WIN32) || defined( _CONSOLE )
#include <winsock.h> /* for SOCKET */
typedef SOCKET LBER_SOCKET;
#else
typedef int LBER_SOCKET;
#endif /* _WINDOWS */
#else /* macintosh */
typedef void *LBER_SOCKET;
#endif /* macintosh */
/* calling conventions used by library */
#ifndef LDAP_CALL
#if defined( _WINDOWS ) || defined( _WIN32 )
#define LDAP_C __cdecl
#ifndef _WIN32
#define __stdcall _far _pascal
#define LDAP_CALLBACK _loadds
#else
#define LDAP_CALLBACK
#endif /* _WIN32 */
#define LDAP_PASCAL __stdcall
#define LDAP_CALL LDAP_PASCAL
#else /* _WINDOWS */
#define LDAP_C
#define LDAP_CALLBACK
#define LDAP_PASCAL
#define LDAP_CALL
#endif /* _WINDOWS */
#endif /* LDAP_CALL */
/*
* function prototypes for lber library
*/
#ifndef LDAP_API
#if defined( _WINDOWS ) || defined( _WIN32 )
#define LDAP_API(rt) rt
#else /* _WINDOWS */
#define LDAP_API(rt) rt
#endif /* _WINDOWS */
#endif /* LDAP_API */
struct lextiof_socket_private; /* Defined by the extended I/O */
/* callback functions */
struct lextiof_session_private; /* Defined by the extended I/O */
/* callback functions */
/*
* libldap read and write I/O function callbacks. The rest of the I/O callback
* types are defined in ldap.h
*/
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_READ_CALLBACK)( LBER_SOCKET s,
void *buf, int bufsize );
typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_WRITE_CALLBACK)( LBER_SOCKET s,
const void *buf, int len );
typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_READ_CALLBACK)( int s,
void *buf, int bufsize, struct lextiof_socket_private *arg );
typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITE_CALLBACK)( int s,
const void *buf, int len, struct lextiof_socket_private *arg );
/*
* Structure for use with LBER_SOCKBUF_OPT_EXT_IO_FNS:
*/
struct lber_x_ext_io_fns {
/* lbextiofn_size should always be set to LBER_X_EXTIO_FNS_SIZE */
int lbextiofn_size;
LDAP_X_EXTIOF_READ_CALLBACK *lbextiofn_read;
LDAP_X_EXTIOF_WRITE_CALLBACK *lbextiofn_write;
struct lextiof_socket_private *lbextiofn_socket_arg;
};
#define LBER_X_EXTIO_FNS_SIZE sizeof(struct lber_x_ext_io_fns)
/*
* liblber memory allocation callback functions. These are global to all
* Sockbufs and BerElements. Install your own functions by using a call
* like this: ber_set_option( NULL, LBER_OPT_MEMALLOC_FN_PTRS, &memalloc_fns );
*/
typedef void * (LDAP_C LDAP_CALLBACK LDAP_MALLOC_CALLBACK)( size_t size );
typedef void * (LDAP_C LDAP_CALLBACK LDAP_CALLOC_CALLBACK)( size_t nelem,
size_t elsize );
typedef void * (LDAP_C LDAP_CALLBACK LDAP_REALLOC_CALLBACK)( void *ptr,
size_t size );
typedef void (LDAP_C LDAP_CALLBACK LDAP_FREE_CALLBACK)( void *ptr );
struct lber_memalloc_fns {
LDAP_MALLOC_CALLBACK *lbermem_malloc;
LDAP_CALLOC_CALLBACK *lbermem_calloc;
LDAP_REALLOC_CALLBACK *lbermem_realloc;
LDAP_FREE_CALLBACK *lbermem_free;
};
/*
* decode routines
*/
LDAP_API(unsigned long) LDAP_CALL ber_get_tag( BerElement *ber );
LDAP_API(unsigned long) LDAP_CALL ber_skip_tag( BerElement *ber,
unsigned long *len );
LDAP_API(unsigned long) LDAP_CALL ber_peek_tag( BerElement *ber,
unsigned long *len );
LDAP_API(unsigned long) LDAP_CALL ber_get_int( BerElement *ber, long *num );
LDAP_API(unsigned long) LDAP_CALL ber_get_stringb( BerElement *ber, char *buf,
unsigned long *len );
LDAP_API(unsigned long) LDAP_CALL ber_get_stringa( BerElement *ber,
char **buf );
LDAP_API(unsigned long) LDAP_CALL ber_get_stringal( BerElement *ber,
struct berval **bv );
LDAP_API(unsigned long) LDAP_CALL ber_get_bitstringa( BerElement *ber,
char **buf, unsigned long *len );
LDAP_API(unsigned long) LDAP_CALL ber_get_null( BerElement *ber );
LDAP_API(unsigned long) LDAP_CALL ber_get_boolean( BerElement *ber,
int *boolval );
LDAP_API(unsigned long) LDAP_CALL ber_first_element( BerElement *ber,
unsigned long *len, char **last );
LDAP_API(unsigned long) LDAP_CALL ber_next_element( BerElement *ber,
unsigned long *len, char *last );
LDAP_API(unsigned long) LDAP_C ber_scanf( BerElement *ber, const char *fmt,
... );
LDAP_API(void) LDAP_CALL ber_bvfree( struct berval *bv );
LDAP_API(void) LDAP_CALL ber_bvecfree( struct berval **bv );
LDAP_API(struct berval *) LDAP_CALL ber_bvdup( const struct berval *bv );
LDAP_API(void) LDAP_CALL ber_set_string_translators( BerElement *ber,
BERTranslateProc encode_proc, BERTranslateProc decode_proc );
LDAP_API(BerElement *) LDAP_CALL ber_init( const struct berval *bv );
/*
* encoding routines
*/
LDAP_API(int) LDAP_CALL ber_put_enum( BerElement *ber, long num,
unsigned long tag );
LDAP_API(int) LDAP_CALL ber_put_int( BerElement *ber, long num,
unsigned long tag );
LDAP_API(int) LDAP_CALL ber_put_ostring( BerElement *ber, char *str,
unsigned long len, unsigned long tag );
LDAP_API(int) LDAP_CALL ber_put_string( BerElement *ber, char *str,
unsigned long tag );
LDAP_API(int) LDAP_CALL ber_put_bitstring( BerElement *ber, char *str,
unsigned long bitlen, unsigned long tag );
LDAP_API(int) LDAP_CALL ber_put_null( BerElement *ber, unsigned long tag );
LDAP_API(int) LDAP_CALL ber_put_boolean( BerElement *ber, int boolval,
unsigned long tag );
LDAP_API(int) LDAP_CALL ber_start_seq( BerElement *ber, unsigned long tag );
LDAP_API(int) LDAP_CALL ber_start_set( BerElement *ber, unsigned long tag );
LDAP_API(int) LDAP_CALL ber_put_seq( BerElement *ber );
LDAP_API(int) LDAP_CALL ber_put_set( BerElement *ber );
LDAP_API(int) LDAP_C ber_printf( BerElement *ber, const char *fmt, ... );
LDAP_API(int) LDAP_CALL ber_flatten( BerElement *ber,
struct berval **bvPtr );
/*
* miscellaneous routines
*/
LDAP_API(void) LDAP_CALL ber_free( BerElement *ber, int freebuf );
LDAP_API(void) LDAP_CALL ber_special_free(void* buf, BerElement *ber);
LDAP_API(int) LDAP_CALL ber_flush( Sockbuf *sb, BerElement *ber, int freeit );
LDAP_API(BerElement*) LDAP_CALL ber_alloc( void );
LDAP_API(BerElement*) LDAP_CALL der_alloc( void );
LDAP_API(BerElement*) LDAP_CALL ber_alloc_t( int options );
LDAP_API(void*) LDAP_CALL ber_special_alloc(size_t size, BerElement **ppBer);
LDAP_API(BerElement*) LDAP_CALL ber_dup( BerElement *ber );
LDAP_API(unsigned long) LDAP_CALL ber_get_next( Sockbuf *sb, unsigned long *len,
BerElement *ber );
LDAP_API(unsigned long) LDAP_CALL ber_get_next_buffer( void *buffer,
size_t buffer_size, unsigned long *len, BerElement *ber,
unsigned long *Bytes_Scanned );
LDAP_API(long) LDAP_CALL ber_read( BerElement *ber, char *buf,
unsigned long len );
LDAP_API(long) LDAP_CALL ber_write( BerElement *ber, char *buf,
unsigned long len, int nosos );
LDAP_API(void) LDAP_CALL ber_init_w_nullchar( BerElement *ber, int options );
LDAP_API(void) LDAP_CALL ber_reset( BerElement *ber, int was_writing );
LDAP_API(int) LDAP_CALL ber_set_option( BerElement *ber, int option,
void *value );
LDAP_API(int) LDAP_CALL ber_get_option( BerElement *ber, int option,
void *value );
LDAP_API(Sockbuf*) LDAP_CALL ber_sockbuf_alloc( void );
LDAP_API(void) LDAP_CALL ber_sockbuf_free( Sockbuf* p );
LDAP_API(int) LDAP_CALL ber_sockbuf_set_option( Sockbuf *sb, int option,
void *value );
LDAP_API(int) LDAP_CALL ber_sockbuf_get_option( Sockbuf *sb, int option,
void *value );
#ifdef __cplusplus
}
#endif
#endif /* _LBER_H */

View File

@@ -0,0 +1,57 @@
/* lcache.h - ldap persistent cache */
#ifndef _LCACHE_H
#define _LCACHE_H
#ifdef __cplusplus
extern "C" {
#endif
/* calling conventions used by library */
#ifndef LDAP_CALL
#if defined( _WINDOWS ) || defined( _WIN32 )
#define LDAP_C __cdecl
#ifndef _WIN32
#define __stdcall _far _pascal
#define LDAP_CALLBACK _loadds
#else
#define LDAP_CALLBACK
#endif /* _WIN32 */
#define LDAP_PASCAL __stdcall
#define LDAP_CALL LDAP_PASCAL
#else /* _WINDOWS */
#define LDAP_C
#define LDAP_CALLBACK
#define LDAP_PASCAL
#define LDAP_CALL
#endif /* _WINDOWS */
#endif /* LDAP_CALL */
LDAP_API(int) LDAP_C lcache_init( LDAP *ld, void *arg );
LDAP_API(int) LDAP_C lcache_bind( LDAP *ld, int msgid, unsigned long tag,
const char *dn, struct berval *cred, int method );
LDAP_API(int) LDAP_C lcache_unbind( LDAP *ld, int msgid, unsigned long tag );
LDAP_API(int) LDAP_C lcache_search( LDAP *ld, int msgid, unsigned long tag,
const char *dn, int scope, const char *filter, char **attrs,
int attrsonly );
LDAP_API(int) LDAP_C lcache_compare( LDAP *ld, int msgid, unsigned long tag,
const char *dn, const char *attr, struct berval *val );
LDAP_API(int) LDAP_C lcache_add( LDAP *ld, int msgid, unsigned long tag,
const char *dn, LDAPMod **entry );
LDAP_API(int) LDAP_C lcache_delete( LDAP *ld, int msgid, unsigned long tag,
const char *dn );
LDAP_API(int) LDAP_C lcache_rename( LDAP *ld, int msgid, unsigned long tag,
const char *dn, const char *newrdn, const char *newparent,
int deleteoldrdn );
LDAP_API(int) LDAP_C lcache_modify( LDAP *ld, int msgid, unsigned long tag,
const char *dn, LDAPMod **mods );
LDAP_API(int) LDAP_C lcache_modrdn( LDAP *ld, int msgid, unsigned long tag,
const char *dn, const char *newrdn, int deleteoldrdn );
LDAP_API(int) LDAP_C lcache_result( LDAP *ld, int msgid, int all,
struct timeval *timeout, LDAPMessage **result );
LDAP_API(int) LDAP_C lcache_flush( LDAP *ld, char *dn, char *filter );
#ifdef __cplusplus
}
#endif
#endif /* _LCACHE_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,135 @@
#if !defined(LDAP_SSL_H)
#define LDAP_SSL_H
/* ldap_ssl.h - prototypes for LDAP over SSL functions */
#ifdef __cplusplus
extern "C" {
#endif
/*
* these three defines resolve the SSL strength
* setting auth weak, diables all cert checking
* the CNCHECK tests for the man in the middle hack
*/
#define LDAPSSL_AUTH_WEAK 0
#define LDAPSSL_AUTH_CERT 1
#define LDAPSSL_AUTH_CNCHECK 2
/*
* Initialize LDAP library for SSL
*/
LDAP * LDAP_CALL ldapssl_init( const char *defhost, int defport,
int defsecure );
/*
* Install I/O routines to make SSL over LDAP possible.
* Use this after ldap_init() or just use ldapssl_init() instead.
*/
int LDAP_CALL ldapssl_install_routines( LDAP *ld );
/* The next three functions initialize the security code for SSL
* The first one ldapssl_client_init() does initialization for SSL only
* The next one supports ldapssl_clientauth_init() intializes security
* for SSL for client authentication. The third function initializes
* security for doing SSL with client authentication, and PKCS, that is,
* the third function initializes the security module database (secmod.db).
* The parameters are as follows:
* const char *certdbpath - path to the cert file. This can be a shortcut
* to the directory name, if so cert7.db will be postfixed to the string.
* void *certdbhandle - Normally this is NULL. This memory will need
* to be freed.
* int needkeydb - boolean. Must be !=0 if client Authentification
* is required
* char *keydbpath - path to the key database. This can be a shortcut
* to the directory name, if so key3.db will be postfixed to the string.
* void *keydbhandle - Normally this is NULL, This memory will need
* to be freed
* int needsecmoddb - boolean. Must be !=0 to assure that the correct
* security module is loaded into memory
* char *secmodpath - path to the secmod. This can be a shortcut to the
* directory name, if so secmod.db will be postfixed to the string.
*
* These three functions are mutually exclusive. You can only call
* one. This means that, for a given process, you must call the
* appropriate initialization function for the life of the process.
*/
/*
* Initialize the secure parts (Security and SSL) of the runtime for use
* by a client application. This is only called once.
*/
int LDAP_CALL ldapssl_client_init(
const char *certdbpath, void *certdbhandle );
/*
* Initialize the secure parts (Security and SSL) of the runtime for use
* by a client application that may want to do SSL client authentication.
*/
int LDAP_CALL ldapssl_clientauth_init(
const char *certdbpath, void *certdbhandle,
const int needkeydb, const char *keydbpath, void *keydbhandle );
/*
* Initialize the secure parts (Security and SSL) of the runtime for use
* by a client application that may want to do SSL client authentication.
*/
int LDAP_CALL ldapssl_advclientauth_init(
const char *certdbpath, void *certdbhandle,
const int needkeydb, const char *keydbpath, void *keydbhandle,
const int needsecmoddb, const char *secmoddbpath,
const int sslstrength );
/*
* get a meaningful error string back from the security library
* this function should be called, if ldap_err2string doesn't
* identify the error code.
*/
const char * LDAP_CALL ldapssl_err2string( const int prerrno );
/*
* Enable SSL client authentication on the given ld.
*/
int LDAP_CALL ldapssl_enable_clientauth( LDAP *ld, char *keynickname,
char *keypasswd, char *certnickname );
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_TOKEN_CALLBACK)(void *context, char **tokenname);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_PIN_CALLBACK)(void *context, const char *tokenname, char **tokenpin);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTPATH_CALLBACK)(void *context, char **certpath);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_KEYPATH_CALLBACK)(void *context,char **keypath);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_MODPATH_CALLBACK)(void *context, char **modulepath);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTNAME_CALLBACK)(void *context, char **certname);
typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK)(void *context, char **filename);
#define PKCS_STRUCTURE_ID 1
struct ldapssl_pkcs_fns {
int local_structure_id;
void *local_data;
LDAP_PKCS_GET_CERTPATH_CALLBACK *pkcs_getcertpath;
LDAP_PKCS_GET_CERTNAME_CALLBACK *pkcs_getcertname;
LDAP_PKCS_GET_KEYPATH_CALLBACK *pkcs_getkeypath;
LDAP_PKCS_GET_MODPATH_CALLBACK *pkcs_getmodpath;
LDAP_PKCS_GET_PIN_CALLBACK *pkcs_getpin;
LDAP_PKCS_GET_TOKEN_CALLBACK *pkcs_gettokenname;
LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK *pkcs_getdonglefilename;
};
LDAP_API(int) LDAP_CALL ldapssl_pkcs_init( const struct ldapssl_pkcs_fns *pfns);
#ifdef __cplusplus
}
#endif
#endif /* !defined(LDAP_SSL_H) */

View File

@@ -0,0 +1,68 @@
#ifndef _LDAPLOG_H
#define _LDAPLOG_H
#ifdef __cplusplus
extern "C" {
#endif
#define LDAP_DEBUG_TRACE 0x00001
#define LDAP_DEBUG_PACKETS 0x00002
#define LDAP_DEBUG_ARGS 0x00004
#define LDAP_DEBUG_CONNS 0x00008
#define LDAP_DEBUG_BER 0x00010
#define LDAP_DEBUG_FILTER 0x00020
#define LDAP_DEBUG_CONFIG 0x00040
#define LDAP_DEBUG_ACL 0x00080
#define LDAP_DEBUG_STATS 0x00100
#define LDAP_DEBUG_STATS2 0x00200
#define LDAP_DEBUG_SHELL 0x00400
#define LDAP_DEBUG_PARSE 0x00800
#define LDAP_DEBUG_HOUSE 0x01000
#define LDAP_DEBUG_REPL 0x02000
#define LDAP_DEBUG_ANY 0x04000
#define LDAP_DEBUG_CACHE 0x08000
#define LDAP_DEBUG_PLUGIN 0x10000
/* debugging stuff */
/* Disable by default */
#define LDAPDebug( level, fmt, arg1, arg2, arg3 )
#ifdef LDAP_DEBUG
# undef LDAPDebug
/* SLAPD_LOGGING should not be on for WINSOCK (16-bit Windows) */
# if defined(SLAPD_LOGGING)
# ifdef _WIN32
extern int *module_ldap_debug;
# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
{ \
if ( *module_ldap_debug & level ) { \
slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \
} \
}
# else /* _WIN32 */
extern int ldap_debug;
# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
{ \
if ( ldap_debug & level ) { \
slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \
} \
}
# endif /* Win32 */
# else /* no SLAPD_LOGGING */
extern void ber_err_print( char * );
extern int ldap_debug;
# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \
if ( ldap_debug & level ) { \
char msg[256]; \
sprintf( msg, fmt, arg1, arg2, arg3 ); \
ber_err_print( msg ); \
}
# endif /* SLAPD_LOGGING */
#endif /* LDAP_DEBUG */
#ifdef __cplusplus
}
#endif
#endif /* _LDAP_H */

View File

@@ -0,0 +1,148 @@
#ifndef LDAP_PR_H
#define LDAP_PR_H
#include "nspr.h"
/*
* ldappr.h - prototypes for functions that tie libldap into NSPR (Netscape
* Portable Runtime).
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Function: prldap_init().
*
* Create a new LDAP session handle, but with NSPR I/O, threading, and DNS
* functions installed.
*
* Pass a non-zero value for the 'shared' parameter if you plan to use
* this LDAP * handle from more than one thread.
*
* Returns an LDAP session handle (or NULL if an error occurs).
*/
LDAP * LDAP_CALL prldap_init( const char *defhost, int defport, int shared );
/*
* Function: prldap_install_routines().
*
* Install NSPR I/O, threading, and DNS functions so they will be used by
* 'ld'.
*
* If 'ld' is NULL, the functions are installed as the default functions
* for all new LDAP * handles).
*
* Pass a non-zero value for the 'shared' parameter if you plan to use
* this LDAP * handle from more than one thread.
*
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well).
*/
int LDAP_CALL prldap_install_routines( LDAP *ld, int shared );
/**
** Note: the types and functions below are only useful for developers
** who need to layer one or more custom extended I/O functions on top of
** the standard NSPR I/O functions installed by a call to prldap_init()
** or prldap_install_routines(). Layering can be accomplished after
** prldap_init() or prldap_install_routines() has completed successfully
** by:
**
** 1) Calling ldap_get_option( ..., LDAP_X_OPT_EXTIO_FN_PTRS, ... ).
**
** 2) Saving the function pointer of one or more of the standard functions.
**
** 3) Replacing one or more standard functions in the ldap_x_ext_io_fns
** struct with new functions that optionally do some preliminary work,
** call the standard function (via the function pointer saved in step 2),
** and optionally do some followup work.
*/
/*
* Data structure for session information.
* seinfo_size should be set to PRLDAP_SESSIONINFO_SIZE before use.
*/
struct prldap_session_private;
typedef struct prldap_session_info {
int seinfo_size;
struct prldap_session_private *seinfo_appdata;
} PRLDAPSessionInfo;
#define PRLDAP_SESSIONINFO_SIZE sizeof( PRLDAPSessionInfo )
/*
* Function: prldap_set_session_info().
*
* Given an LDAP session handle or a session argument such is passed to
* SOCKET, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks,
* set some application-specific data. If ld is NULL, arg is used. If
* both ld and arg are NULL, LDAP_PARAM_ERROR is returned.
*
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well).
*/
int LDAP_CALL prldap_set_session_info( LDAP *ld, void *sessionarg,
PRLDAPSessionInfo *seip );
/*
* Function: prldap_get_session_info().
*
* Given an LDAP session handle or a session argument such is passed to
* SOCKET, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks,
* retrieve some application-specific data. If ld is NULL, arg is used. If
* both ld and arg are NULL, LDAP_PARAM_ERROR is returned.
*
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
* which case the fields in the structure that seip points to are filled in).
*/
int LDAP_CALL prldap_get_session_info( LDAP *ld, void *sessionarg,
PRLDAPSessionInfo *seip );
/*
* Data structure for socket specific information.
* Note: soinfo_size should be set to PRLDAP_SOCKETINFO_SIZE before use.
*/
struct prldap_socket_private;
typedef struct prldap_socket_info {
int soinfo_size;
PRFileDesc *soinfo_prfd;
struct prldap_socket_private *soinfo_appdata;
} PRLDAPSocketInfo;
#define PRLDAP_SOCKETINFO_SIZE sizeof( PRLDAPSocketInfo )
/*
* Function: prldap_set_socket_info().
*
* Given an integer fd and a socket argument such as those passed to the
* extended I/O callback functions, set socket specific information.
*
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well).
*
* Note: it is only safe to change soinfo_prfd from within the SOCKET
* extended I/O callback function.
*/
int LDAP_CALL prldap_set_socket_info( int fd, void *socketarg,
PRLDAPSocketInfo *soip );
/*
* Function: prldap_get_socket_info().
*
* Given an integer fd and a socket argument such as those passed to the
* extended I/O callback functions, retrieve socket specific information.
*
* Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in
* which case the fields in the structure that soip points to are filled in).
*/
int LDAP_CALL prldap_get_socket_info( int fd, void *socketarg,
PRLDAPSocketInfo *soip );
#ifdef __cplusplus
}
#endif
#endif /* !defined(LDAP_PR_H) */

View File

@@ -0,0 +1,158 @@
#ifndef _LDAPROT_H
#define _LDAPROT_H
#ifdef __cplusplus
extern "C" {
#endif
#define LDAP_VERSION1 1
#define LDAP_VERSION2 2
#define LDAP_VERSION3 3
#define LDAP_VERSION LDAP_VERSION2
#define COMPAT20
#define COMPAT30
#if defined(COMPAT20) || defined(COMPAT30)
#define COMPAT
#endif
#define LDAP_URL_PREFIX "ldap://"
#define LDAP_URL_PREFIX_LEN 7
#define LDAPS_URL_PREFIX "ldaps://"
#define LDAPS_URL_PREFIX_LEN 8
#define LDAP_REF_STR "Referral:\n"
#define LDAP_REF_STR_LEN 10
/*
* specific LDAP instantiations of BER types we know about
*/
/* general stuff */
#define LDAP_TAG_MESSAGE 0x30L /* tag is 16 + constructed bit */
#define OLD_LDAP_TAG_MESSAGE 0x10L /* forgot the constructed bit */
#define LDAP_TAG_MSGID 0x02L /* INTEGER */
#define LDAP_TAG_LDAPDN 0x04L /* OCTET STRING */
#define LDAP_TAG_CONTROLS 0xa0L /* context specific + constructed + 0 */
#define LDAP_TAG_REFERRAL 0xa3L /* context specific + constructed + 3 */
#define LDAP_TAG_NEWSUPERIOR 0x80L /* context specific + primitive + 0 */
#define LDAP_TAG_MRA_OID 0x81L /* context specific + primitive + 1 */
#define LDAP_TAG_MRA_TYPE 0x82L /* context specific + primitive + 2 */
#define LDAP_TAG_MRA_VALUE 0x83L /* context specific + primitive + 3 */
#define LDAP_TAG_MRA_DNATTRS 0x84L /* context specific + primitive + 4 */
#define LDAP_TAG_EXOP_REQ_OID 0x80L /* context specific + primitive + 0 */
#define LDAP_TAG_EXOP_REQ_VALUE 0x81L /* context specific + primitive + 1 */
#define LDAP_TAG_EXOP_RES_OID 0x8aL /* context specific + primitive + 10 */
#define LDAP_TAG_EXOP_RES_VALUE 0x8bL /* context specific + primitive + 11 */
#define LDAP_TAG_SK_MATCHRULE 0x80L /* context specific + primitive + 0 */
#define LDAP_TAG_SK_REVERSE 0x81L /* context specific + primitive + 1 */
#define LDAP_TAG_SR_ATTRTYPE 0x80L /* context specific + primitive + 0 */
#define LDAP_TAG_SASL_RES_CREDS 0x87L /* context specific + primitive + 7 */
#define LDAP_TAG_VLV_BY_INDEX 0xa0L /* context specific + constructed + 0 */
#define LDAP_TAG_VLV_BY_VALUE 0x81L /* context specific + primitive + 1 */
/* possible operations a client can invoke */
#define LDAP_REQ_BIND 0x60L /* application + constructed + 0 */
#define LDAP_REQ_UNBIND 0x42L /* application + primitive + 2 */
#define LDAP_REQ_SEARCH 0x63L /* application + constructed + 3 */
#define LDAP_REQ_MODIFY 0x66L /* application + constructed + 6 */
#define LDAP_REQ_ADD 0x68L /* application + constructed + 8 */
#define LDAP_REQ_DELETE 0x4aL /* application + primitive + 10 */
#define LDAP_REQ_MODRDN 0x6cL /* application + constructed + 12 */
#define LDAP_REQ_MODDN 0x6cL /* application + constructed + 12 */
#define LDAP_REQ_RENAME 0x6cL /* application + constructed + 12 */
#define LDAP_REQ_COMPARE 0x6eL /* application + constructed + 14 */
#define LDAP_REQ_ABANDON 0x50L /* application + primitive + 16 */
#define LDAP_REQ_EXTENDED 0x77L /* application + constructed + 23 */
/* U-M LDAP release 3.0 compatibility stuff */
#define LDAP_REQ_UNBIND_30 0x62L
#define LDAP_REQ_DELETE_30 0x6aL
#define LDAP_REQ_ABANDON_30 0x70L
/*
* old broken stuff for backwards compatibility - forgot application tag
* and constructed/primitive bit
*/
#define OLD_LDAP_REQ_BIND 0x00L
#define OLD_LDAP_REQ_UNBIND 0x02L
#define OLD_LDAP_REQ_SEARCH 0x03L
#define OLD_LDAP_REQ_MODIFY 0x06L
#define OLD_LDAP_REQ_ADD 0x08L
#define OLD_LDAP_REQ_DELETE 0x0aL
#define OLD_LDAP_REQ_MODRDN 0x0cL
#define OLD_LDAP_REQ_MODDN 0x0cL
#define OLD_LDAP_REQ_COMPARE 0x0eL
#define OLD_LDAP_REQ_ABANDON 0x10L
/* old broken stuff for backwards compatibility */
#define OLD_LDAP_RES_BIND 0x01L
#define OLD_LDAP_RES_SEARCH_ENTRY 0x04L
#define OLD_LDAP_RES_SEARCH_RESULT 0x05L
#define OLD_LDAP_RES_MODIFY 0x07L
#define OLD_LDAP_RES_ADD 0x09L
#define OLD_LDAP_RES_DELETE 0x0bL
#define OLD_LDAP_RES_MODRDN 0x0dL
#define OLD_LDAP_RES_MODDN 0x0dL
#define OLD_LDAP_RES_COMPARE 0x0fL
/* U-M LDAP 3.0 compatibility auth methods */
#define LDAP_AUTH_SIMPLE_30 0xa0L /* context specific + constructed */
#define LDAP_AUTH_KRBV41_30 0xa1L /* context specific + constructed */
#define LDAP_AUTH_KRBV42_30 0xa2L /* context specific + constructed */
/* old broken stuff */
#define OLD_LDAP_AUTH_SIMPLE 0x00L
#define OLD_LDAP_AUTH_KRBV4 0x01L
#define OLD_LDAP_AUTH_KRBV42 0x02L
/* U-M LDAP 3.0 compatibility filter types */
#define LDAP_FILTER_PRESENT_30 0xa7L /* context specific + constructed */
/* filter types */
#define LDAP_FILTER_AND 0xa0L /* context specific + constructed + 0 */
#define LDAP_FILTER_OR 0xa1L /* context specific + constructed + 1 */
#define LDAP_FILTER_NOT 0xa2L /* context specific + constructed + 2 */
#define LDAP_FILTER_EQUALITY 0xa3L /* context specific + constructed + 3 */
#define LDAP_FILTER_SUBSTRINGS 0xa4L /* context specific + constructed + 4 */
#define LDAP_FILTER_GE 0xa5L /* context specific + constructed + 5 */
#define LDAP_FILTER_LE 0xa6L /* context specific + constructed + 6 */
#define LDAP_FILTER_PRESENT 0x87L /* context specific + primitive + 7 */
#define LDAP_FILTER_APPROX 0xa8L /* context specific + constructed + 8 */
#define LDAP_FILTER_EXTENDED 0xa9L /* context specific + constructed + 0 */
/* old broken stuff */
#define OLD_LDAP_FILTER_AND 0x00L
#define OLD_LDAP_FILTER_OR 0x01L
#define OLD_LDAP_FILTER_NOT 0x02L
#define OLD_LDAP_FILTER_EQUALITY 0x03L
#define OLD_LDAP_FILTER_SUBSTRINGS 0x04L
#define OLD_LDAP_FILTER_GE 0x05L
#define OLD_LDAP_FILTER_LE 0x06L
#define OLD_LDAP_FILTER_PRESENT 0x07L
#define OLD_LDAP_FILTER_APPROX 0x08L
/* substring filter component types */
#define LDAP_SUBSTRING_INITIAL 0x80L /* context specific + primitive + 0 */
#define LDAP_SUBSTRING_ANY 0x81L /* context specific + primitive + 1 */
#define LDAP_SUBSTRING_FINAL 0x82L /* context specific + primitive + 2 */
/* extended filter component types */
#define LDAP_FILTER_EXTENDED_OID 0x81L /* context spec. + prim. + 1 */
#define LDAP_FILTER_EXTENDED_TYPE 0x82L /* context spec. + prim. + 2 */
#define LDAP_FILTER_EXTENDED_VALUE 0x83L /* context spec. + prim. + 3 */
#define LDAP_FILTER_EXTENDED_DNATTRS 0x84L /* context spec. + prim. + 4 */
/* U-M LDAP 3.0 compatibility substring filter component types */
#define LDAP_SUBSTRING_INITIAL_30 0xa0L /* context specific */
#define LDAP_SUBSTRING_ANY_30 0xa1L /* context specific */
#define LDAP_SUBSTRING_FINAL_30 0xa2L /* context specific */
/* old broken stuff */
#define OLD_LDAP_SUBSTRING_INITIAL 0x00L
#define OLD_LDAP_SUBSTRING_ANY 0x01L
#define OLD_LDAP_SUBSTRING_FINAL 0x02L
#ifdef __cplusplus
}
#endif
#endif /* _LDAPROT_H */

View File

@@ -0,0 +1,362 @@
/* ldbm.h - ldap dbm compatibility routine header file */
#ifndef _LDBM_H_
#define _LDBM_H_
/* define LDAP_USE_DB185 to get the old db library, otherwise, use db2.0 */
#ifndef LDAP_USE_DB185
#define LDAP_USE_DB20
#endif
#ifdef LDBM_USE_GDBM
/*****************************************************************
* *
* use gdbm if possible *
* *
*****************************************************************/
#include <gdbm.h>
typedef datum Datum;
typedef GDBM_FILE LDBM;
extern gdbm_error gdbm_errno;
/* for ldbm_open */
#define LDBM_READER GDBM_READER
#define LDBM_WRITER GDBM_WRITER
#define LDBM_WRCREAT GDBM_WRCREAT
#define LDBM_NEWDB GDBM_NEWDB
#define LDBM_FAST GDBM_FAST
#define LDBM_SUFFIX ".gdbm"
/* for ldbm_insert */
#define LDBM_INSERT GDBM_INSERT
#define LDBM_REPLACE GDBM_REPLACE
#define LDBM_SYNC 0x80000000
#else /* end of gdbm */
#ifdef LDBM_USE_DBHASH
/*****************************************************************
* *
* use berkeley db hash package *
* *
*****************************************************************/
#include <sys/types.h>
#include <limits.h>
#include <fcntl.h>
#include <errno.h>
#include <db.h>
typedef DBT Datum;
#define dsize size
#define dptr data
typedef DB *LDBM;
#define DB_TYPE DB_HASH
/* for ldbm_open */
#define LDBM_READER O_RDONLY
#define LDBM_WRITER O_RDWR
#define LDBM_WRCREAT (O_RDWR|O_CREAT)
#define LDBM_NEWDB (O_RDWR|O_TRUNC|O_CREAT)
#define LDBM_FAST 0
#define LDBM_SUFFIX ".dbh"
/* for ldbm_insert */
#define LDBM_INSERT R_NOOVERWRITE
#define LDBM_REPLACE 0
#define LDBM_SYNC 0x80000000
#else /* end of db hash */
#ifdef LDBM_USE_DBBTREE
/*****************************************************************
* *
* use berkeley db btree package *
* *
*****************************************************************/
#ifndef LDAP_USE_DB20 /* old-db needed us to include these system headers first */
#include <sys/types.h>
#include <limits.h>
#include <fcntl.h>
#include <errno.h>
#endif
#include <db.h>
#define DB_TYPE DB_BTREE
#define LDBM_ORDERED 1
#ifdef LDAP_USE_DB20
/* pull in parts of the new interface , this comes from dblayer.h */
typedef struct _tag_dblayer_session{
DB_ENV db_env;
} *dblayer_session, dblayer_session_struct;
/* for ldbm_insert */
#define LDBM_INSERT DB_NOOVERWRITE
#define LDBM_REPLACE 0 /* Db2.0 default is to replace */
#define LDBM_SYNC 0x80000000
typedef DBT Datum;
#define dsize size
#define dptr data
typedef struct _ldbm {
DB *pReal_DB;
DBC *pCursor;
} _ldbmstruct, *LDBM;
/* for ldbm_open */
#define LDBM_READER DB_RDONLY
#define LDBM_WRITER 0
#define LDBM_WRCREAT DB_CREATE
#define LDBM_NEWDB (DB_TRUNCATE | DB_CREATE)
#define LDBM_FAST 0
#define LDBM_SUFFIX ".db2"
#else /* DB 1.85 */
/* for ldbm_insert */
#define LDBM_INSERT R_NOOVERWRITE
#define LDBM_REPLACE 0
#define LDBM_SYNC 0x80000000
typedef DBT Datum;
#define dsize size
#define dptr data
typedef DB *LDBM;
/* for ldbm_open */
#define LDBM_READER O_RDONLY
#define LDBM_WRITER O_RDWR
#define LDBM_WRCREAT (O_RDWR|O_CREAT)
#define LDBM_NEWDB (O_RDWR|O_TRUNC|O_CREAT)
#define LDBM_FAST 0
#define LDBM_SUFFIX ".dbb"
#endif /* LDAP_USE_DB20 */
#else /* end of db btree */
#ifdef LDBM_USE_NDBM
/*****************************************************************
* *
* if none of the above use ndbm, the standard unix thing *
* *
*****************************************************************/
#include <ndbm.h>
#ifndef O_RDONLY
#include <fcntl.h>
#endif
typedef datum Datum;
typedef DBM *LDBM;
/* for ldbm_open */
#define LDBM_READER O_RDONLY
#define LDBM_WRITER O_WRONLY
#define LDBM_WRCREAT (O_RDWR|O_CREAT)
#define LDBM_NEWDB (O_RDWR|O_TRUNC|O_CREAT)
#define LDBM_FAST 0
#define LDBM_SUFFIX ".ndbm"
/* for ldbm_insert */
#define LDBM_INSERT DBM_INSERT
#define LDBM_REPLACE DBM_REPLACE
#define LDBM_SYNC 0
#else /* end of ndbm */
#ifdef LDBM_USE_CISAM
/*****************************************************************
* *
* use CISAM db package *
* *
*****************************************************************/
#include <sys/types.h>
#include <sys/errno.h>
#include <limits.h>
#include <fcntl.h>
#include "isam.h"
extern int errno;
struct datum {
void *dptr; /* data */
size_t dsize; /* data length */
};
typedef struct datum Datum;
struct ldbm {
int fd; /* all callers expect a ptr */
int cur_recnum; /* for reading sequentially */
};
typedef struct ldbm *LDBM;
/* for ldbm_open */
#define LDBM_READER (ISINPUT | ISVARLEN | ISMANULOCK)
#define LDBM_WRITER (ISINOUT | ISVARLEN | ISMANULOCK)
#define LDBM_WRCREAT (ISINOUT | ISVARLEN | ISMANULOCK | ISEXCLLOCK)
#define LDBM_NEWDB (ISINOUT | ISVARLEN | ISMANULOCK | ISEXCLLOCK)
#define LDBM_FAST 0
#define LDBM_SUFFIX ""
#define LDBM_ORDERED 1
/* for ldbm_insert */
#define LDBM_INSERT 1
#define LDBM_REPLACE 0
#define LDBM_SYNC 0x80000000
#else /* end of cisam */
#ifdef LDBM_USE_TRIO
/*****************************************************************
* *
* use C-Index/II from Trio *
* *
*****************************************************************/
#include <sys/types.h>
#include <sys/errno.h>
#include <limits.h>
#include <fcntl.h>
#include "cndx.h"
#define CRDCREAT 0x100
extern int errno;
struct datum {
void *dptr; /* data */
size_t dsize; /* data length */
};
typedef struct datum Datum;
typedef CFILE *LDBM;
/* for ldbm_open */
#define LDBM_READER (CRDONLY)
#define LDBM_WRITER (CRDWRITE)
#define LDBM_WRCREAT (CRDWRITE | CRDCREAT)
#define LDBM_NEWDB (CRDWRITE | CRDCREAT)
#define LDBM_FAST 0
#define LDBM_SUFFIX ".c2i"
#define LDBM_ORDERED 1
/* for ldbm_insert */
#define LDBM_INSERT 1
#define LDBM_REPLACE 0
#define LDBM_SYNC 0x80000000
#else /* end of trio */
#ifdef LDBM_USE_CTREE
/*****************************************************************
* *
* use Faircom Ctree db package *
* *
*****************************************************************/
#include <sys/types.h>
#include <sys/errno.h>
#include <limits.h>
#include <fcntl.h>
#include "ctstdr.h"
#include "ctoptn.h"
#include "ctaerr.h"
#include "ctdecl.h"
#include "cterrc.h"
extern int errno;
struct datum {
void *dptr; /* data */
size_t dsize; /* data length */
};
typedef struct datum Datum;
typedef IFIL *LDBM;
/* for ldbm_open */
#define LDBM_READER 0
#define LDBM_WRITER 0
#define LDBM_WRCREAT 1
#define LDBM_NEWDB 1
#define LDBM_FAST 0
#define LDBM_SUFFIX ""
#define LDBM_ORDERED 1
/* for ldbm_insert */
#define LDBM_INSERT 1
#define LDBM_REPLACE 0
#define LDBM_SYNC 0x80000000
#endif /* ctree */
#endif /* trio */
#endif /* cisam */
#endif /* ndbm */
#endif /* db hash */
#endif /* db btree */
#endif /* gdbm */
/*
* name: file name without the suffix
* rw: read/write flags
* mode: this has the desired permissions mode on the file
* dbcachesize: advisory cache size in bytes
*/
LDBM ldbm_open( char *name, int rw, int mode, int dbcachesize );
#ifdef LDAP_USE_DB20
/* This is a stopgap measure to allow us to associate a session with ldbm_ calls */
LDBM ldbm_open2( dblayer_session session, char *name, int rw, int mode);
/* These are stolen from beta2's dblayer.h */
int dblayer_session_open(char *home_dir, char* log_dir, char* temp_dir, int cachesize, dblayer_session session) ;
int dblayer_session_terminate(dblayer_session session) ;
#endif
int ldbm_close( LDBM ldbm );
void ldbm_sync( LDBM ldbm );
void ldbm_datum_free( LDBM ldbm, Datum data );
Datum ldbm_datum_dup( LDBM ldbm, Datum data );
Datum ldbm_fetch( LDBM ldbm, Datum key );
int ldbm_store( LDBM ldbm, Datum key, Datum data, int flags );
int ldbm_delete( LDBM ldbm, Datum key );
Datum ldbm_firstkey( LDBM ldbm );
Datum ldbm_nextkey( LDBM ldbm, Datum key );
Datum ldbm_prevkey( LDBM ldbm, Datum key );
Datum ldbm_lastkey( LDBM ldbm );
Datum ldbm_cursorkey( LDBM ldbm, Datum key );
int ldbm_errno( LDBM ldbm );
#endif /* _ldbm_h_ */

View File

@@ -0,0 +1,70 @@
/*
* Copyright (c) 1996 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* 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.
*/
#ifndef _LDIF_H
#define _LDIF_H
#ifdef __cplusplus
extern "C" {
#endif
#define LDIF_VERSION_ONE 1 /* LDIF standard version */
#define LDIF_MAX_LINE_WIDTH 76 /* maximum length of LDIF lines */
/*
* Macro to calculate maximum number of bytes that the base64 equivalent
* of an item that is "vlen" bytes long will take up. Base64 encoding
* uses one byte for every six bits in the value plus up to two pad bytes.
*/
#define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3)
/*
* Macro to calculate maximum size that an LDIF-encoded type (length
* tlen) and value (length vlen) will take up: room for type + ":: " +
* first newline + base64 value + continued lines. Each continued line
* needs room for a newline and a leading space character.
*/
#define LDIF_SIZE_NEEDED(tlen,vlen) \
((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
+ ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LDIF_MAX_LINE_WIDTH * 2 ))
/*
* Options for ldif_put_type_and_value_with_options() and
* ldif_type_and_value_with_options().
*/
#define LDIF_OPT_NOWRAP 0x01UL
#define LDIF_OPT_VALUE_IS_URL 0x02UL
#define LDIF_OPT_MINIMAL_ENCODING 0x04UL
int ldif_parse_line( char *line, char **type, char **value, int *vlen);
char * ldif_getline( char **next );
void ldif_put_type_and_value( char **out, char *t, char *val, int vlen );
void ldif_put_type_and_value_nowrap( char **out, char *t, char *val, int vlen );
void ldif_put_type_and_value_with_options( char **out, char *t, char *val,
int vlen, unsigned long options );
char *ldif_type_and_value( char *type, char *val, int vlen );
char *ldif_type_and_value_nowrap( char *type, char *val, int vlen );
char *ldif_type_and_value_with_options( char *type, char *val, int vlen,
unsigned long options );
int ldif_base64_decode( char *src, unsigned char *dst );
int ldif_base64_encode( unsigned char *src, char *dst, int srclen,
int lenused );
int ldif_base64_encode_nowrap( unsigned char *src, char *dst, int srclen,
int lenused );
char *ldif_get_entry( FILE *fp, int *lineno );
#ifdef __cplusplus
}
#endif
#endif /* _LDIF_H */

View File

@@ -0,0 +1,418 @@
/* lthread.h - ldap threads header file */
#ifndef _LTHREAD_H
#define _LTHREAD_H
#if defined( THREAD_SUNOS4_LWP )
/***********************************
* *
* thread definitions for sunos4 *
* *
***********************************/
#define _THREAD
#include <lwp/lwp.h>
#include <lwp/stackdep.h>
typedef void *(*VFP)();
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef thread_t pthread_t;
/* default attr states */
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1
/* thread scope - who is in scheduling pool */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 1
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef mon_t pthread_mutex_t;
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 1
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
typedef struct lwpcv {
int lcv_created;
cv_t lcv_cv;
} pthread_cond_t;
#else /* end sunos4 */
#if defined( THREAD_SUNOS5_LWP )
/***********************************
* *
* thread definitions for sunos5 *
* *
***********************************/
#define _THREAD
#include <thread.h>
#include <synch.h>
typedef void *(*VFP)();
/* sunos5 threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef thread_t pthread_t;
/* default attr states */
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED THR_DETACHED
/* thread scope - who is in scheduling pool */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM THR_BOUND
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef mutex_t pthread_mutex_t;
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE USYNC_THREAD
#define PTHREAD_SHARE_PROCESS USYNC_PROCESS
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
typedef cond_t pthread_cond_t;
#else /* end sunos5 */
#if defined( THREAD_MIT_PTHREADS )
/***********************************
* *
* definitions for mit pthreads *
* *
***********************************/
#define _THREAD
#include <pthread.h>
#else /* end mit pthreads */
#if defined( THREAD_AIX_PTHREADS )
/***********************************
* *
* definitions for aix pthreads *
* *
***********************************/
#define _THREAD
#include <pthread.h>
typedef void *(*VFP)(void *);
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
/* default attr states */
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
#else /* aix pthreads */
#if defined( THREAD_HP_DCE_PTHREADS )
/**************************************
* *
* definitions for HP dce pthreads *
* *
**************************************/
#define _THREAD
typedef void *(*VFP)();
#include <pthread.h>
/* dce threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
/* pthread_kill() is a noop on HP */
#define PTHREAD_KILL_IS_NOOP 1
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1
#define pthread_attr_init( a ) pthread_attr_create( a )
#define pthread_attr_destroy( a ) pthread_attr_delete( a )
#define pthread_attr_setdetachstate( a, b ) \
pthread_attr_setdetach_np( a, b )
/*
* HP's DCE threads implementation passes a (pthread_attr_t *)
* for the second argument. So, we need to fake things a bit.
* hpdce_pthread_create_detached() is in thread.c. Note that we
* create threads and detach them. If you need to create a joinable
* thread, you need to call hpdce_pthread_create_joinable() directly.
*/
#define pthread_create( a, b, c, d ) \
hpdce_pthread_create_detached( a, b, c, d )
int
hpdce_pthread_create_joinable( pthread_t *tid, pthread_attr_t *attr,
VFP func, void *arg );
int hpdce_pthread_create_detached( pthread_t *tid, pthread_attr_t *attr,
VFP func, void *arg );
#else /* HP dce pthreads */
#if defined( THREAD_DCE_PTHREADS )
/***********************************
* *
* definitions for dce pthreads *
* *
***********************************/
#define _THREAD
typedef void *(*VFP)();
#include <pthread.h>
/* dce threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
/* thread state - joinable or not */
#ifndef PTHREAD_CREATE_JOINABLE
#define PTHREAD_CREATE_JOINABLE 0
#endif
#ifndef PTHREAD_CREATE_DETACHED
#define PTHREAD_CREATE_DETACHED 1
#endif
#define pthread_attr_init( a ) pthread_attr_create( a )
#define pthread_attr_destroy( a ) pthread_attr_delete( a )
#define pthread_attr_setdetachstate( a, b ) \
pthread_attr_setdetach_np( a, b )
#if defined( OSF1 )
/* pthread_create's second parameter is passed by value, not by reference.
* To work around this, call another function instead:
*/
#define pthread_create( a, b, c, d ) std_pthread_create( a, b, c, d )
extern int
std_pthread_create (pthread_t *tid,
pthread_attr_t *attr,
pthread_startroutine_t func,
pthread_addr_t arg); /* defined in thread.c */
/* OSF1 doesn't support pthread_kill() */
#define PTHREAD_KILL_IS_NOOP 1
#endif /* OSF1 */
#else /* dce pthreads */
#if defined( THREAD_SGI_SPROC )
/***********************************
* *
* thread definitions for sgi irix *
* *
***********************************/
#define _THREAD
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/procset.h>
#include <sys/prctl.h>
#include <ulocks.h>
typedef void *(*VFP)(void *);
/* sgi threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef pid_t pthread_t;
/* default attr states */
#define pthread_mutexattr_default 0
#define pthread_condattr_default 0
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1
/* thread scope - who is in scheduling pool */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 1
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef int pthread_mutex_t;
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 1
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
struct irix_cv_waiter {
pid_t icvw_pid;
struct irix_cv_waiter *icvw_next;
};
typedef struct irix_cv {
pthread_mutex_t icv_mutex;
pthread_mutex_t *icv_waitermutex;
struct irix_cv_waiter *icv_waiterq;
} pthread_cond_t;
#else
#if defined( WIN32_KERNEL_THREADS )
/***********************************
* *
* thread definitions for Win32 *
* *
***********************************/
#define _THREAD
#include <windows.h>
#include <process.h>
#include "ldap.h"
#include "ldaplog.h"
typedef void (*VFP)(void *);
/* Win32 threads are preemptive */
#define PTHREAD_PREEMPTIVE 1
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef HANDLE pthread_t;
/* default attr states */
#define pthread_mutexattr_default 0
#define pthread_condattr_default 0
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1
/* thread scope - who is in scheduling pool */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 1
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef HANDLE pthread_mutex_t;
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 1
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
/* simulated condition variable */
struct win32_cv_waiter {
pthread_t icvw_pthread;
struct win32_cv_waiter *icvw_next;
};
typedef struct win32_cv {
pthread_mutex_t icv_mutex;
pthread_mutex_t *icv_waitermutex;
struct win32_cv_waiter *icv_waiterq;
} pthread_cond_t;
#endif /* NATIVE_WIN32_THREADS */
#endif /* sgi sproc */
#endif /* dce pthreads */
#endif /* hp dce pthreads */
#endif /* aix pthreads */
#endif /* mit pthreads */
#endif /* sunos5 */
#endif /* sunos4 */
#ifndef _THREAD
/***********************************
* *
* thread definitions for no *
* underlying library support *
* *
***********************************/
typedef void *(*VFP)();
/* thread attributes and thread type */
typedef int pthread_attr_t;
typedef int pthread_t;
/* default attr states */
#define pthread_mutexattr_default NULL
#define pthread_condattr_default NULL
/* thread state - joinable or not */
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 0
/* thread scope - who is in scheduling pool */
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 0
/* mutex attributes and mutex type */
typedef int pthread_mutexattr_t;
typedef int pthread_mutex_t;
/* mutex and condition variable scope - process or system */
#define PTHREAD_SHARE_PRIVATE 0
#define PTHREAD_SHARE_PROCESS 0
/* condition variable attributes and condition variable type */
typedef int pthread_condattr_t;
typedef int pthread_cond_t;
#endif /* no threads support */
/* POSIX standard pthread function declarations: */
int pthread_attr_init( pthread_attr_t *attr );
int pthread_attr_destroy( pthread_attr_t *attr );
int pthread_attr_getdetachstate( pthread_attr_t *attr, int *detachstate );
int pthread_attr_setdetachstate( pthread_attr_t *attr, int detachstate );
int pthread_create( pthread_t *tid, pthread_attr_t *attr, VFP func, void *arg );
void pthread_yield();
void pthread_exit();
int pthread_kill( pthread_t tid, int sig );
#if defined( hpux ) || defined( OSF1 ) || defined( AIXV4 ) /* <thread.h> declares pthread_join */
#else
int pthread_join( pthread_t tid, int *status );
#endif
#if defined( hpux ) || defined( OSF1 ) /* <thread.h> declares pthread_mutex_init */
#else
int pthread_mutex_init( pthread_mutex_t *mp, pthread_mutexattr_t *attr );
#endif
int pthread_mutex_destroy( pthread_mutex_t *mp );
int pthread_mutex_lock( pthread_mutex_t *mp );
int pthread_mutex_unlock( pthread_mutex_t *mp );
int pthread_mutex_trylock( pthread_mutex_t *mp );
#if defined( hpux ) || defined( OSF1 ) /* <thread.h> declares pthread_cond_init */
#else
int pthread_cond_init( pthread_cond_t *cv, pthread_condattr_t *attr );
#endif
int pthread_cond_destroy( pthread_cond_t *cv );
int pthread_cond_wait( pthread_cond_t *cv, pthread_mutex_t *mp );
int pthread_cond_signal( pthread_cond_t *cv );
int pthread_cond_broadcast( pthread_cond_t *cv );
#endif /* _LTHREAD_H */

View File

@@ -0,0 +1,39 @@
/******************************************************
*
* Copyright (c) 1996 Netscape Communications Corp.
* This code is proprietary and is a trade secret of
* Netscape Communications Corp.
*
* ntslapdregparms.h - NT Registry keys for Slapd.
*
******************************************************/
#if defined( _WIN32 )
#if !defined( _NTSLAPDREGPARMS_H_ )
#define _NTSLAPDREGPARMS_H_
#define COMPANY_KEY "SOFTWARE\\Netscape"
#define COMPANY_NAME "Netscape"
#define PROGRAM_GROUP_NAME "Netscape"
#define PRODUCT_NAME "slapd"
#define PRODUCT_BIN "ns-slapd"
#define SLAPD_EXE "slapd.exe"
#define SERVICE_EXE SLAPD_EXE
#define SLAPD_CONF "slapd.conf"
#define MAGNUS_CONF SLAPD_CONF
#define SLAPD_DONGLE_FILE "password.dng"
#define DONGLE_FILE_NAME SLAPD_DONGLE_FILE
#define PRODUCT_VERSION "1.0"
#define EVENTLOG_APPNAME "NetscapeSlapd"
#define DIRECTORY_SERVICE_PREFIX "Netscape Directory Server "
#define SERVICE_PREFIX DIRECTORY_SERVICE_PREFIX
#define CONFIG_PATH_KEY "ConfigurationPath"
#define EVENTLOG_MESSAGES_KEY "EventMessageFile"
#define EVENT_LOG_KEY "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application"
#define ADMIN_REGISTRY_ROOT_KEY "Admin Server"
#define SLAPD_REGISTRY_ROOT_KEY "Slapd Server"
#define PRODUCT_KEY SLAPD_REGISTRY_ROOT_KEY
#endif /* _NTSLAPDREGPARMS_H_ */
#endif /* _WIN32 */

View File

@@ -0,0 +1,57 @@
/******************************************************
*
* Copyright (c) 1996 Netscape Communications Corp.
* This code is proprietary and is a trade secret of
* Netscape Communications Corp.
*
* ntwatchdog.h - Defs for NT Watchdog Service.
*
******************************************************/
#if defined( _WIN32 )
#if !defined( _NTWATCHDOG_H_ )
#define _NTWATCHDOG_H_
#define FILE_PATHSEP '/'
#define SLAPD_ROOT "SLAPD_ROOT" // environment variable holding server root path
#define MORTALITY_KEY "MortalityTimeSecs"
#define MINRAMFREE_KEY "MinRamFree"
#define MINRAMTOTAL_KEY "MinRamTotal"
#define MINRAMPERSERVER_KEY "MinRamPerServer"
#define DEFAULT_MORTALITY_TIME 60 // seconds after startup up until server will NOT be restarted
#define DEFAULT_KILL_TIME 60 // seconds to wait for httpd.exe to shutdown
#define DEFAULT_CRON_TIME 60 // seconds to wait before rechecking cron.conf
#define DEFAULT_RESTART_TIME 10 // seconds to wait before restarting server
#define DEFAULT_MINRAMFREE 0 // KB free physical memory remaining
#define DEFAULT_MINRAMTOTAL (30 * 1024) // KB free physical memory installed
#define DEFAULT_MINRAMPERSERVER (15 * 1024) // KB free physical memory per server
#define MSG_RESOURCES "Not enough physical memory to start server."
// offsets for extra window bytes, used in Set/GetWindowLong()
#define GWL_PROCESS_HANDLE (sizeof(LONG) * 0)
#define GWL_PASSWORD_ADDR (sizeof(LONG) * 1)
#define GWL_PASSWORD_LENGTH (sizeof(LONG) * 2)
#define MAX_LINE 512
#define MAX_PASSWORD 256
#define CLOSEHANDLE(X) \
{ \
if(X) \
{ \
CloseHandle(X); \
X = 0; \
} \
}
// in ntcron.c
LPTHREAD_START_ROUTINE CRON_ThreadProc(HANDLE hevWatchDogExit);
// in watchdog.c
BOOL WD_SysLog(WORD fwEventType, DWORD IDEvent, char *szData);
#endif /* _NTWATCHDOG_H_ */
#endif /* _WIN32 */

Some files were not shown because too many files have changed in this diff Show More