mhonek / rpms / openldap

Forked from rpms/openldap 3 years ago
Clone
ac27aa7
diff -up evo-openldap-2.4.14/include/ldap.h.evolution-ntlm evo-openldap-2.4.14/include/ldap.h
ac27aa7
--- evo-openldap-2.4.14/include/ldap.h.evolution-ntlm	2009-01-27 00:29:53.000000000 +0100
ac27aa7
+++ evo-openldap-2.4.14/include/ldap.h	2009-02-17 10:10:00.000000000 +0100
ac27aa7
@@ -2461,5 +2461,26 @@ ldap_parse_deref_control LDAP_P((
ac27aa7
 	LDAPControl	**ctrls,
ac27aa7
 	LDAPDerefRes	**drp ));
cvsdist 37375b1
 
cvsdist 37375b1
+/*
cvsdist 37375b1
+ * hacks for NTLM
cvsdist 37375b1
+ */
cvsdist 37375b1
+#define LDAP_AUTH_NTLM_REQUEST	((ber_tag_t) 0x8aU)
cvsdist 37375b1
+#define LDAP_AUTH_NTLM_RESPONSE	((ber_tag_t) 0x8bU)
cvsdist 37375b1
+LDAP_F( int )
cvsdist 37375b1
+ldap_ntlm_bind LDAP_P((
cvsdist 37375b1
+	LDAP		*ld,
cvsdist 37375b1
+	LDAP_CONST char	*dn,
cvsdist 37375b1
+	ber_tag_t	tag,
cvsdist 37375b1
+	struct berval	*cred,
cvsdist 37375b1
+	LDAPControl	**sctrls,
cvsdist 37375b1
+	LDAPControl	**cctrls,
cvsdist 37375b1
+	int		*msgidp ));
cvsdist 37375b1
+LDAP_F( int )
cvsdist 37375b1
+ldap_parse_ntlm_bind_result LDAP_P((
cvsdist 37375b1
+	LDAP		*ld,
cvsdist 37375b1
+	LDAPMessage	*res,
cvsdist 37375b1
+	struct berval	*challenge));
cvsdist 37375b1
+
cvsdist 37375b1
+
cvsdist 37375b1
 LDAP_END_DECL
cvsdist 37375b1
 #endif /* _LDAP_H */
ac27aa7
diff -up evo-openldap-2.4.14/libraries/libldap/Makefile.in.evolution-ntlm evo-openldap-2.4.14/libraries/libldap/Makefile.in
ac27aa7
--- evo-openldap-2.4.14/libraries/libldap/Makefile.in.evolution-ntlm	2009-01-27 00:29:53.000000000 +0100
ac27aa7
+++ evo-openldap-2.4.14/libraries/libldap/Makefile.in	2009-02-17 10:10:00.000000000 +0100
d5ef856
@@ -20,7 +20,7 @@ PROGRAMS = apitest dntest ftest ltest ur
cvsdist 37375b1
 SRCS	= bind.c open.c result.c error.c compare.c search.c \
cvsdist 37375b1
 	controls.c messages.c references.c extended.c cyrus.c \
cvsdist 37375b1
 	modify.c add.c modrdn.c delete.c abandon.c \
ac27aa7
-	sasl.c gssapi.c sbind.c unbind.c cancel.c  \
ac27aa7
+	sasl.c ntlm.c gssapi.c sbind.c unbind.c cancel.c  \
cvsdist 37375b1
 	filter.c free.c sort.c passwd.c whoami.c \
cvsdist 37375b1
 	getdn.c getentry.c getattr.c getvalues.c addentry.c \
d5ef856
 	request.c os-ip.c url.c pagectrl.c sortctrl.c vlvctrl.c \
ac27aa7
@@ -33,7 +33,7 @@ SRCS	= bind.c open.c result.c error.c co
cvsdist 37375b1
 OBJS	= bind.lo open.lo result.lo error.lo compare.lo search.lo \
cvsdist 37375b1
 	controls.lo messages.lo references.lo extended.lo cyrus.lo \
cvsdist 37375b1
 	modify.lo add.lo modrdn.lo delete.lo abandon.lo \
ac27aa7
-	sasl.lo gssapi.lo sbind.lo unbind.lo cancel.lo \
ac27aa7
+	sasl.lo ntlm.lo gssapi.lo sbind.lo unbind.lo cancel.lo \
cvsdist 37375b1
 	filter.lo free.lo sort.lo passwd.lo whoami.lo \
cvsdist 37375b1
 	getdn.lo getentry.lo getattr.lo getvalues.lo addentry.lo \
d5ef856
 	request.lo os-ip.lo url.lo pagectrl.lo sortctrl.lo vlvctrl.lo \
ac27aa7
diff -up /dev/null evo-openldap-2.4.14/libraries/libldap/ntlm.c
ac27aa7
--- /dev/null	2009-02-17 09:19:52.829004420 +0100
ac27aa7
+++ evo-openldap-2.4.14/libraries/libldap/ntlm.c	2009-02-17 10:10:00.000000000 +0100
cvsdist 37375b1
@@ -0,0 +1,137 @@
cvsdist 37375b1
+/* $OpenLDAP: pkg/ldap/libraries/libldap/ntlm.c,v 1.1.4.10 2002/01/04 20:38:21 kurt Exp $ */
cvsdist 37375b1
+/*
cvsdist 37375b1
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
cvsdist 37375b1
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
cvsdist 37375b1
+ */
cvsdist 37375b1
+
cvsdist 37375b1
+/* Mostly copied from sasl.c */
cvsdist 37375b1
+
cvsdist 37375b1
+#include "portable.h"
cvsdist 37375b1
+
cvsdist 37375b1
+#include <stdlib.h>
cvsdist 37375b1
+#include <stdio.h>
cvsdist 37375b1
+
cvsdist 37375b1
+#include <ac/socket.h>
cvsdist 37375b1
+#include <ac/string.h>
cvsdist 37375b1
+#include <ac/time.h>
cvsdist 37375b1
+#include <ac/errno.h>
cvsdist 37375b1
+
cvsdist 37375b1
+#include "ldap-int.h"
cvsdist 37375b1
+
cvsdist 37375b1
+int
cvsdist 37375b1
+ldap_ntlm_bind(
cvsdist 37375b1
+	LDAP		*ld,
cvsdist 37375b1
+	LDAP_CONST char	*dn,
cvsdist 37375b1
+	ber_tag_t	tag,
cvsdist 37375b1
+	struct berval	*cred,
cvsdist 37375b1
+	LDAPControl	**sctrls,
cvsdist 37375b1
+	LDAPControl	**cctrls,
cvsdist 37375b1
+	int		*msgidp )
cvsdist 37375b1
+{
cvsdist 37375b1
+	BerElement	*ber;
cvsdist 37375b1
+	int rc;
cvsdist 37375b1
+	ber_int_t id;
cvsdist 37375b1
+
cvsdist 37375b1
+	Debug( LDAP_DEBUG_TRACE, "ldap_ntlm_bind\n", 0, 0, 0 );
cvsdist 37375b1
+
cvsdist 37375b1
+	assert( ld != NULL );
cvsdist 37375b1
+	assert( LDAP_VALID( ld ) );
cvsdist 37375b1
+	assert( msgidp != NULL );
cvsdist 37375b1
+
cvsdist 37375b1
+	if( msgidp == NULL ) {
cvsdist 37375b1
+		ld->ld_errno = LDAP_PARAM_ERROR;
cvsdist 37375b1
+		return ld->ld_errno;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	/* create a message to send */
cvsdist 37375b1
+	if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
cvsdist 37375b1
+		ld->ld_errno = LDAP_NO_MEMORY;
cvsdist 37375b1
+		return ld->ld_errno;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	assert( LBER_VALID( ber ) );
cvsdist 37375b1
+
cvsdist 37375b1
+	LDAP_NEXT_MSGID( ld, id );
cvsdist 37375b1
+	rc = ber_printf( ber, "{it{istON}" /*}*/,
cvsdist 37375b1
+			 id, LDAP_REQ_BIND,
cvsdist 37375b1
+			 ld->ld_version, dn, tag,
cvsdist 37375b1
+			 cred );
cvsdist 37375b1
+
cvsdist 37375b1
+	/* Put Server Controls */
cvsdist 37375b1
+	if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
cvsdist 37375b1
+		ber_free( ber, 1 );
cvsdist 37375b1
+		return ld->ld_errno;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	if ( ber_printf( ber, /*{*/ "N}" ) == -1 ) {
cvsdist 37375b1
+		ld->ld_errno = LDAP_ENCODING_ERROR;
cvsdist 37375b1
+		ber_free( ber, 1 );
cvsdist 37375b1
+		return ld->ld_errno;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	/* send the message */
cvsdist 37375b1
+	*msgidp = ldap_send_initial_request( ld, LDAP_REQ_BIND, dn, ber, id );
cvsdist 37375b1
+
cvsdist 37375b1
+	if(*msgidp < 0)
cvsdist 37375b1
+		return ld->ld_errno;
cvsdist 37375b1
+
cvsdist 37375b1
+	return LDAP_SUCCESS;
cvsdist 37375b1
+}
cvsdist 37375b1
+
cvsdist 37375b1
+int
cvsdist 37375b1
+ldap_parse_ntlm_bind_result(
cvsdist 37375b1
+	LDAP		*ld,
cvsdist 37375b1
+	LDAPMessage	*res,
cvsdist 37375b1
+	struct berval	*challenge)
cvsdist 37375b1
+{
cvsdist 37375b1
+	ber_int_t	errcode;
cvsdist 37375b1
+	ber_tag_t	tag;
cvsdist 37375b1
+	BerElement	*ber;
cvsdist 37375b1
+	ber_len_t	len;
cvsdist 37375b1
+
cvsdist 37375b1
+	Debug( LDAP_DEBUG_TRACE, "ldap_parse_ntlm_bind_result\n", 0, 0, 0 );
cvsdist 37375b1
+
cvsdist 37375b1
+	assert( ld != NULL );
cvsdist 37375b1
+	assert( LDAP_VALID( ld ) );
cvsdist 37375b1
+	assert( res != NULL );
cvsdist 37375b1
+
cvsdist 37375b1
+	if ( ld == NULL || res == NULL ) {
cvsdist 37375b1
+		return LDAP_PARAM_ERROR;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	if( res->lm_msgtype != LDAP_RES_BIND ) {
cvsdist 37375b1
+		ld->ld_errno = LDAP_PARAM_ERROR;
cvsdist 37375b1
+		return ld->ld_errno;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	if ( ld->ld_error ) {
cvsdist 37375b1
+		LDAP_FREE( ld->ld_error );
cvsdist 37375b1
+		ld->ld_error = NULL;
cvsdist 37375b1
+	}
cvsdist 37375b1
+	if ( ld->ld_matched ) {
cvsdist 37375b1
+		LDAP_FREE( ld->ld_matched );
cvsdist 37375b1
+		ld->ld_matched = NULL;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	/* parse results */
cvsdist 37375b1
+
cvsdist 37375b1
+	ber = ber_dup( res->lm_ber );
cvsdist 37375b1
+
cvsdist 37375b1
+	if( ber == NULL ) {
cvsdist 37375b1
+		ld->ld_errno = LDAP_NO_MEMORY;
cvsdist 37375b1
+		return ld->ld_errno;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	tag = ber_scanf( ber, "{ioa" /*}*/,
cvsdist 37375b1
+			 &errcode, challenge, &ld->ld_error );
cvsdist 37375b1
+	ber_free( ber, 0 );
cvsdist 37375b1
+
cvsdist 37375b1
+	if( tag == LBER_ERROR ) {
cvsdist 37375b1
+		ld->ld_errno = LDAP_DECODING_ERROR;
cvsdist 37375b1
+		return ld->ld_errno;
cvsdist 37375b1
+	}
cvsdist 37375b1
+
cvsdist 37375b1
+	ld->ld_errno = errcode;
cvsdist 37375b1
+
cvsdist 37375b1
+	return( ld->ld_errno );
cvsdist 37375b1
+}