From 8a0a7fe367f16fbad6740472fb6fa311f0482c5d Mon Sep 17 00:00:00 2001
From: Kurt Zeilenga <kurt@openldap.org>
Date: Tue, 20 Oct 1998 18:59:12 +0000
Subject: [PATCH] VC++ round 2

---
 clients/tools/ldapdelete.c   | 18 ++++---
 clients/tools/ldapdelete.dsp | 91 ++++++++++++++++++++++++++++++++++
 clients/tools/ldapdelete.dsw | 29 +++++++++++
 clients/tools/ldapmodify.c   | 19 +++++---
 clients/tools/ldapmodify.dsp | 94 ++++++++++++++++++++++++++++++++++++
 clients/tools/ldapmodify.dsw | 29 +++++++++++
 clients/tools/ldapmodrdn.c   | 21 +++++---
 clients/tools/ldapmodrdn.dsp | 85 ++++++++++++++++++++++++++++++++
 clients/tools/ldapmodrdn.dsw | 29 +++++++++++
 clients/tools/ldapsearch.c   | 54 ++++++++++++++-------
 clients/tools/ldapsearch.dsp | 91 ++++++++++++++++++++++++++++++++++
 clients/tools/ldapsearch.dsw | 29 +++++++++++
 12 files changed, 550 insertions(+), 39 deletions(-)
 create mode 100644 clients/tools/ldapdelete.dsp
 create mode 100644 clients/tools/ldapdelete.dsw
 create mode 100644 clients/tools/ldapmodify.dsp
 create mode 100644 clients/tools/ldapmodify.dsw
 create mode 100644 clients/tools/ldapmodrdn.dsp
 create mode 100644 clients/tools/ldapmodrdn.dsw
 create mode 100644 clients/tools/ldapsearch.dsp
 create mode 100644 clients/tools/ldapsearch.dsw

diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c
index 8ce9adf7f1..49c1763e12 100644
--- a/clients/tools/ldapdelete.c
+++ b/clients/tools/ldapdelete.c
@@ -1,12 +1,13 @@
 /* ldapdelete.c - simple program to delete an entry using LDAP */
 
-#define DISABLE_BRIDGE
 #include "portable.h"
 
 #include <stdio.h>
-#include <ac/string.h>
 #include <stdlib.h>
 #include <ctype.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
 #include <ac/time.h>
 
 #include <lber.h>
@@ -29,15 +30,18 @@ extern int ldap_debug, lber_debug;
 #define safe_realloc( ptr, size )	( ptr == NULL ? malloc( size ) : \
 					 realloc( ptr, size ))
 
+static int dodelete LDAP_P((
+    LDAP	*ld,
+    char	*dn));
 
 main( argc, argv )
     int		argc;
     char	**argv;
 {
     char		*usage = "usage: %s [-n] [-v] [-k] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
-    char		*p, buf[ 4096 ];
+    char		buf[ 4096 ];
     FILE		*fp;
-    int			i, rc, kerberos, linenum, authmethod;
+    int			i, rc, kerberos, authmethod;
 
     extern char	*optarg;
     extern int	optind;
@@ -138,9 +142,9 @@ main( argc, argv )
 }
 
 
-dodelete( ld, dn )
-    LDAP	*ld;
-    char	*dn;
+static int dodelete(
+    LDAP	*ld,
+    char	*dn)
 {
     int	rc;
 
diff --git a/clients/tools/ldapdelete.dsp b/clients/tools/ldapdelete.dsp
new file mode 100644
index 0000000000..1cc7da7efb
--- /dev/null
+++ b/clients/tools/ldapdelete.dsp
@@ -0,0 +1,91 @@
+# Microsoft Developer Studio Project File - Name="ldapdelete" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=ldapdelete - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "ldapdelete.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "ldapdelete.mak" CFG="ldapdelete - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "ldapdelete - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "ldapdelete - Win32 Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "ldapdelete - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release\ldapdelete"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "ldapdelete - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug\ldapdelete"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "ldapdelete - Win32 Release"
+# Name "ldapdelete - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\ldapdelete.c
+# End Source File
+# End Target
+# End Project
diff --git a/clients/tools/ldapdelete.dsw b/clients/tools/ldapdelete.dsw
new file mode 100644
index 0000000000..a80886b827
--- /dev/null
+++ b/clients/tools/ldapdelete.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "ldapdelete"=.\ldapdelete.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c
index 31e770cdb3..9f5d127381 100644
--- a/clients/tools/ldapmodify.c
+++ b/clients/tools/ldapmodify.c
@@ -1,18 +1,23 @@
 /* ldapmodify.c - generic program to modify or add entries using LDAP */
 
-#define DISABLE_BRIDGE
 #include "portable.h"
 
 #include <stdio.h>
-#include <ac/string.h>
 #include <stdlib.h>
 #include <ctype.h>
-#include <sys/types.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
+
 #include <sys/stat.h>
+
+#ifdef HAVE_SYS_FILE_H
 #include <sys/file.h>
+#endif
+#ifdef HAVE_FCNTL_H
 #include <fcntl.h>
-
-#include <ac/unistd.h>
+#endif
 
 #include <lber.h>
 #include <ldap.h>
@@ -603,7 +608,7 @@ domodify( char *dn, LDAPMod **pmods, int newentry )
 		for ( j = 0; pmods[ i ]->mod_bvalues[ j ] != NULL; ++j ) {
 		    bvp = pmods[ i ]->mod_bvalues[ j ];
 		    notascii = 0;
-		    for ( k = 0; k < bvp->bv_len; ++k ) {
+		    for ( k = 0; (unsigned long) k < bvp->bv_len; ++k ) {
 			if ( !isascii( bvp->bv_val[ k ] )) {
 			    notascii = 1;
 			    break;
@@ -751,7 +756,7 @@ fromfile( char *path, struct berval *bv )
 	eof = feof( fp );
 	fclose( fp );
 
-	if ( rlen != bv->bv_len ) {
+	if ( (unsigned long) rlen != bv->bv_len ) {
 		perror( path );
 		free( bv->bv_val );
 		return( -1 );
diff --git a/clients/tools/ldapmodify.dsp b/clients/tools/ldapmodify.dsp
new file mode 100644
index 0000000000..e0f35fdf7f
--- /dev/null
+++ b/clients/tools/ldapmodify.dsp
@@ -0,0 +1,94 @@
+# Microsoft Developer Studio Project File - Name="ldapmodify" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=ldapmodify - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "ldapmodify.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "ldapmodify.mak" CFG="ldapmodify - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "ldapmodify - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "ldapmodify - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "ldapmodify - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release\ldapmodify"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
+# ADD LINK32 libldap.lib liblber.lib liblutil.lib /nologo /subsystem:windows /machine:I386
+
+!ELSEIF  "$(CFG)" == "ldapmodify - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "ldapmodi"
+# PROP BASE Intermediate_Dir "ldapmodi"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug\ldapmodify"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 libldap.lib liblber.lib liblutil.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "ldapmodify - Win32 Release"
+# Name "ldapmodify - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\ldapmodify.c
+# End Source File
+# End Target
+# End Project
diff --git a/clients/tools/ldapmodify.dsw b/clients/tools/ldapmodify.dsw
new file mode 100644
index 0000000000..6bd7b7ff98
--- /dev/null
+++ b/clients/tools/ldapmodify.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "ldapmodify"=.\ldapmodify.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c
index d5f578f594..8eae7ff01f 100644
--- a/clients/tools/ldapmodrdn.c
+++ b/clients/tools/ldapmodrdn.c
@@ -4,9 +4,10 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <ac/string.h>
 #include <stdlib.h>
 #include <ctype.h>
+
+#include <ac/string.h>
 #include <ac/time.h>
 
 #include <lber.h>
@@ -29,16 +30,20 @@ extern int ldap_debug, lber_debug;
 #define safe_realloc( ptr, size )	( ptr == NULL ? malloc( size ) : \
 					 realloc( ptr, size ))
 
+static int domodrdn LDAP_P((
+    LDAP	*ld,
+    char	*dn,
+    char	*rdn,
+    int		remove));	/* flag: remove old RDN */
 
 main( argc, argv )
     int		argc;
     char	**argv;
 {
     char		*usage = "usage: %s [-nvkc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
-    char		*myname,*infile, *p, *entrydn, *rdn, buf[ 4096 ];
+    char		*myname,*infile, *entrydn, *rdn, buf[ 4096 ];
     FILE		*fp;
     int			rc, i, kerberos, remove, havedn, authmethod;
-    LDAPMod		**pmods;
 
     extern char	*optarg;
     extern int	optind;
@@ -170,11 +175,11 @@ main( argc, argv )
     exit( rc );
 }
 
-domodrdn( ld, dn, rdn, remove )
-    LDAP	*ld;
-    char	*dn;
-    char	*rdn;
-    int		remove;	/* flag: remove old RDN */
+static int domodrdn(
+    LDAP	*ld,
+    char	*dn,
+    char	*rdn,
+    int		remove)	/* flag: remove old RDN */
 {
     int	i;
 
diff --git a/clients/tools/ldapmodrdn.dsp b/clients/tools/ldapmodrdn.dsp
new file mode 100644
index 0000000000..22a3a8acf3
--- /dev/null
+++ b/clients/tools/ldapmodrdn.dsp
@@ -0,0 +1,85 @@
+# Microsoft Developer Studio Project File - Name="ldapmodrdn" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=ldapmodrdn - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "ldapmodrdn.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "ldapmodrdn.mak" CFG="ldapmodrdn - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "ldapmodrdn - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "ldapmodrdn - Win32 Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "ldapmodrdn - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "ldapmodrdn - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "ldapmodrdn - Win32 Release"
+# Name "ldapmodrdn - Win32 Debug"
+# End Target
+# End Project
diff --git a/clients/tools/ldapmodrdn.dsw b/clients/tools/ldapmodrdn.dsw
new file mode 100644
index 0000000000..d3518543a8
--- /dev/null
+++ b/clients/tools/ldapmodrdn.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "ldapmodrdn"=.\ldapmodrdn.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c
index 3423aba941..5418a4dd8b 100644
--- a/clients/tools/ldapsearch.c
+++ b/clients/tools/ldapsearch.c
@@ -1,9 +1,10 @@
-#define DISABLE_BRIDGE
 #include "portable.h"
 
 #include <stdio.h>
-#include <ac/string.h>
 #include <ctype.h>
+
+#include <ac/socket.h>
+#include <ac/string.h>
 #include <ac/time.h>
 
 #include <lber.h>
@@ -19,7 +20,7 @@ extern int ldap_debug, lber_debug;
 #endif /* LDAP_DEBUG */
 
 
-usage( s )
+static void usage( s )
 char	*s;
 {
     fprintf( stderr, "usage: %s [options] filter [attributes...]\nwhere:\n", s );
@@ -56,6 +57,25 @@ char	*s;
     exit( 1 );
 }
 
+static void print_entry LDAP_P((
+    LDAP	*ld,
+    LDAPMessage	*entry,
+    int		attrsonly));
+
+static int write_ldif_value LDAP_P((
+	char *type,
+	char *value,
+	unsigned long vallen ));
+
+static int dosearch LDAP_P((
+	LDAP	*ld,
+    char	*base,
+    int		scope,
+    char	**attrs,
+    int		attrsonly,
+    char	*filtpatt,
+    char	*value));
+
 static char	*binddn = LDAPSEARCH_BINDDN;
 static char	*passwd = LDAPSEARCH_BIND_CRED;
 static char	*base = LDAPSEARCH_BASE;
@@ -299,16 +319,16 @@ char	**argv;
 }
 
 
-dosearch( ld, base, scope, attrs, attrsonly, filtpatt, value )
-    LDAP	*ld;
-    char	*base;
-    int		scope;
-    char	**attrs;
-    int		attrsonly;
-    char	*filtpatt;
-    char	*value;
+static int dosearch(
+	LDAP	*ld,
+    char	*base,
+    int		scope,
+    char	**attrs,
+    int		attrsonly,
+    char	*filtpatt,
+    char	*value)
 {
-    char		filter[ BUFSIZ ], **val;
+    char		filter[ BUFSIZ ];
     int			rc, first, matches;
     LDAPMessage		*res, *e;
 
@@ -376,10 +396,10 @@ dosearch( ld, base, scope, attrs, attrsonly, filtpatt, value )
 }
 
 
-print_entry( ld, entry, attrsonly )
-    LDAP	*ld;
-    LDAPMessage	*entry;
-    int		attrsonly;
+void print_entry(
+    LDAP	*ld,
+    LDAPMessage	*entry,
+    int		attrsonly)
 {
     char		*a, *dn, *ufn, tmpfname[ 64 ];
     int			i, j, notascii;
@@ -441,7 +461,7 @@ print_entry( ld, entry, attrsonly )
 		} else {
 		    notascii = 0;
 		    if ( !allow_binary ) {
-			for ( j = 0; j < bvals[ i ]->bv_len; ++j ) {
+			for ( j = 0; (unsigned long) j < bvals[ i ]->bv_len; ++j ) {
 			    if ( !isascii( bvals[ i ]->bv_val[ j ] )) {
 				notascii = 1;
 				break;
diff --git a/clients/tools/ldapsearch.dsp b/clients/tools/ldapsearch.dsp
new file mode 100644
index 0000000000..ed1096e93e
--- /dev/null
+++ b/clients/tools/ldapsearch.dsp
@@ -0,0 +1,91 @@
+# Microsoft Developer Studio Project File - Name="ldapsearch" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=ldapsearch - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE 
+!MESSAGE NMAKE /f "ldapsearch.mak".
+!MESSAGE 
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "ldapsearch.mak" CFG="ldapsearch - Win32 Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "ldapsearch - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "ldapsearch - Win32 Debug" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE 
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "ldapsearch - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release\ldapsearch"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 libldap.lib liblber.lib liblutil.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF  "$(CFG)" == "ldapsearch - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug\ldapsearch"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 libldap.lib liblber.lib liblutil.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF 
+
+# Begin Target
+
+# Name "ldapsearch - Win32 Release"
+# Name "ldapsearch - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\ldapsearch.c
+# End Source File
+# End Target
+# End Project
diff --git a/clients/tools/ldapsearch.dsw b/clients/tools/ldapsearch.dsw
new file mode 100644
index 0000000000..97a9e5c53e
--- /dev/null
+++ b/clients/tools/ldapsearch.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "ldapsearch"=.\ldapsearch.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
-- 
GitLab