And here is the patch cleaned up against python-ldap 2.3.10

Thanks,
Chris Dukes
Binary files python-ldap.TLS_PROTOCOL_MIN/build/lib.linux-i686-2.5/_ldap.so and python-ldap/build/lib.linux-i686-2.5/_ldap.so differ
Binary files python-ldap.TLS_PROTOCOL_MIN/dist/python_ldap-2.3.10-py2.5-linux-i686.egg and python-ldap/dist/python_ldap-2.3.10-py2.5-linux-i686.egg differ
diff -urwp python-ldap.TLS_PROTOCOL_MIN/Lib/python_ldap.egg-info/SOURCES.txt python-ldap/Lib/python_ldap.egg-info/SOURCES.txt
--- python-ldap.TLS_PROTOCOL_MIN/Lib/python_ldap.egg-info/SOURCES.txt	2009-10-22 13:10:12.000000000 -0400
+++ python-ldap/Lib/python_ldap.egg-info/SOURCES.txt	2009-10-22 13:17:27.000000000 -0400
@@ -52,7 +52,9 @@ Lib/ldap/schema/subentry.py
 Lib/ldap/schema/tokenizer.py
 Lib/python_ldap.egg-info/PKG-INFO
 Lib/python_ldap.egg-info/SOURCES.txt
+Lib/python_ldap.egg-info/SOURCES.txt.orig
 Lib/python_ldap.egg-info/dependency_links.txt
+Lib/python_ldap.egg-info/native_libs.txt
 Lib/python_ldap.egg-info/not-zip-safe
 Lib/python_ldap.egg-info/requires.txt
 Lib/python_ldap.egg-info/top_level.txt
Only in python-ldap/Lib/python_ldap.egg-info: SOURCES.txt.orig
diff -urwp python-ldap.TLS_PROTOCOL_MIN/Modules/errors.c python-ldap/Modules/errors.c
--- python-ldap.TLS_PROTOCOL_MIN/Modules/errors.c	2009-04-17 08:19:09.000000000 -0400
+++ python-ldap/Modules/errors.c	2009-10-22 13:15:40.000000000 -0400
@@ -45,7 +45,7 @@ LDAPerr(int errnum)
 
 /* Convert an LDAP error into an informative python exception */
 PyObject*
-LDAPerror( LDAP*l, char*msg ) 
+LDAPerror( LDAP*l, char*msg, int msgid ) 
 {
 	if (l == NULL) {
 		PyErr_SetFromErrno( LDAPexception_class );
@@ -91,6 +91,11 @@ LDAPerror( LDAP*l, char*msg ) 
 		    ldap_memfree(matched);
 		}
 		
+                if (msgid >= 0) {
+                    str = PyInt_FromLong((long)msgid);
+                    PyDict_SetItemString( info, "msgid", str );
+                }
+		
 		if (errnum == LDAP_REFERRAL) {
 		    str = PyString_FromString(msg);
 		    if (str)
diff -urwp python-ldap.TLS_PROTOCOL_MIN/Modules/errors.h python-ldap/Modules/errors.h
--- python-ldap.TLS_PROTOCOL_MIN/Modules/errors.h	2009-04-17 08:19:09.000000000 -0400
+++ python-ldap/Modules/errors.h	2009-10-22 13:15:40.000000000 -0400
@@ -9,7 +9,7 @@
 #include "ldap.h"
 
 extern PyObject* LDAPexception_class;
-extern PyObject* LDAPerror( LDAP*, char*msg );
+extern PyObject* LDAPerror( LDAP*, char*msg, int msgid );
 extern void LDAPinit_errors( PyObject* );
 PyObject* LDAPerr(int errnum);
 
diff -urwp python-ldap.TLS_PROTOCOL_MIN/Modules/functions.c python-ldap/Modules/functions.c
--- python-ldap.TLS_PROTOCOL_MIN/Modules/functions.c	2009-08-17 01:00:57.000000000 -0400
+++ python-ldap/Modules/functions.c	2009-10-22 13:15:40.000000000 -0400
@@ -24,7 +24,7 @@ l_ldap_initialize(PyObject* unused, PyOb
     ret = ldap_initialize(&ld, uri);
     Py_END_ALLOW_THREADS
     if (ret != LDAP_SUCCESS)
-    	return LDAPerror(ld, "ldap_initialize");
+    	return LDAPerror(ld, "ldap_initialize", -1);
     return (PyObject*)newLDAPObject(ld);
 }
 
Only in python-ldap/Modules: functions.c.orig
diff -urwp python-ldap.TLS_PROTOCOL_MIN/Modules/LDAPObject.c python-ldap/Modules/LDAPObject.c
--- python-ldap.TLS_PROTOCOL_MIN/Modules/LDAPObject.c	2009-10-08 14:22:44.000000000 -0400
+++ python-ldap/Modules/LDAPObject.c	2009-10-22 13:17:01.000000000 -0400
@@ -355,7 +355,7 @@ l_ldap_unbind_ext( LDAPObject* self, PyO
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_unbind_ext" );
+    	return LDAPerror( self->ldap, "ldap_unbind_ext", -1 );
 
     self->valid = 0;
     Py_INCREF(Py_None);
@@ -396,7 +396,7 @@ l_ldap_abandon_ext( LDAPObject* self, Py
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_abandon_ext" );
+    	return LDAPerror( self->ldap, "ldap_abandon_ext", -1 );
 
     Py_INCREF(Py_None);
     return Py_None;
@@ -443,7 +443,7 @@ l_ldap_add_ext( LDAPObject* self, PyObje
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_add_ext" );
+    	return LDAPerror( self->ldap, "ldap_add_ext", -1 );
 
     return PyInt_FromLong(msgid);
 }
@@ -486,7 +486,7 @@ l_ldap_simple_bind( LDAPObject* self, Py
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_simple_bind" );
+    	return LDAPerror( self->ldap, "ldap_simple_bind", -1 );
 
     return PyInt_FromLong( msgid );
 }
@@ -684,7 +684,7 @@ l_ldap_sasl_interactive_bind_s( LDAPObje
     LDAPControl_List_DEL( client_ldcs );
 
     if (msgid != LDAP_SUCCESS)
-    	return LDAPerror( self->ldap, "ldap_sasl_interactive_bind_s" );
+    	return LDAPerror( self->ldap, "ldap_sasl_interactive_bind_s", -1 );
     return PyInt_FromLong( msgid );
 }
 #endif
@@ -727,7 +727,7 @@ l_ldap_cancel( LDAPObject* self, PyObjec
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_cancel" );
+    	return LDAPerror( self->ldap, "ldap_cancel", -1 );
 
     return PyInt_FromLong( msgid );
 }
@@ -773,7 +773,7 @@ l_ldap_compare_ext( LDAPObject* self, Py
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_compare_ext" );
+    	return LDAPerror( self->ldap, "ldap_compare_ext", -1 );
 
     return PyInt_FromLong( msgid );
 }
@@ -814,7 +814,7 @@ l_ldap_delete_ext( LDAPObject* self, PyO
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_delete_ext" );
+    	return LDAPerror( self->ldap, "ldap_delete_ext", -1 );
 
     return PyInt_FromLong(msgid);
 }
@@ -862,7 +862,7 @@ l_ldap_modify_ext( LDAPObject* self, PyO
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_modify_ext" );
+    	return LDAPerror( self->ldap, "ldap_modify_ext", -1 );
 
     return PyInt_FromLong( msgid );
 }
@@ -906,7 +906,7 @@ l_ldap_rename( LDAPObject* self, PyObjec
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_rename" );
+    	return LDAPerror( self->ldap, "ldap_rename", -1 );
 
     return PyInt_FromLong( msgid );
 }
@@ -925,7 +925,7 @@ l_ldap_result3( LDAPObject* self, PyObje
     int res_type;
     LDAPMessage *msg = NULL;
     PyObject *result_str, *retval, *pmsg, *pyctrls = 0;
-    int res_msgid = 0;
+    int res_msgid = -1;
 
     if (!PyArg_ParseTuple( args, "|iid", &msgid, &all, &timeout ))
     	return NULL;
@@ -942,8 +942,11 @@ l_ldap_result3( LDAPObject* self, PyObje
     res_type = ldap_result( self->ldap, msgid, all, tvp, &msg );
     LDAP_END_ALLOW_THREADS( self );
 
+    if (msg)
+	    res_msgid = ldap_msgid(msg);
+
     if (res_type < 0)	/* LDAP or system error */
-    	return LDAPerror( self->ldap, "ldap_result3" );
+    	return LDAPerror( self->ldap, "ldap_result3", res_msgid );
 
     if (res_type == 0) {
 	/* Polls return (None, None, None, None); timeouts raise an exception */
@@ -953,9 +956,6 @@ l_ldap_result3( LDAPObject* self, PyObje
 		return LDAPerr(LDAP_TIMEOUT);
     }
 
-    if (msg)
-	    res_msgid = ldap_msgid(msg);
-
     int result;
     char **refs = NULL;
     LDAPControl **serverctrls = 0;
@@ -972,14 +972,14 @@ l_ldap_result3( LDAPObject* self, PyObje
 	} else
 	    e = "ldap_parse_result";
 	ldap_msgfree(msg);
-	return LDAPerror( self->ldap, e );
+	return LDAPerror( self->ldap, e, res_msgid );
     }
 
     if (!(pyctrls = LDAPControls_to_List(serverctrls))) {
 	int err = LDAP_NO_MEMORY;
 	ldap_set_option(self->ldap, LDAP_OPT_ERROR_NUMBER, &err);
 	ldap_msgfree(msg);
-	return LDAPerror(self->ldap, "LDAPControls_to_List");
+	return LDAPerror(self->ldap, "LDAPControls_to_List", res_msgid );
     }
     ldap_controls_free(serverctrls);
 
@@ -1071,7 +1071,7 @@ l_ldap_search_ext( LDAPObject* self, PyO
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_search_ext" );
+    	return LDAPerror( self->ldap, "ldap_search_ext", -1 );
 
     return PyInt_FromLong( msgid );
 }	
@@ -1113,7 +1113,7 @@ l_ldap_whoami_s( LDAPObject* self, PyObj
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_whoami_s" );
+    	return LDAPerror( self->ldap, "ldap_whoami_s", -1 );
 
     result = LDAPberval_to_object(bvalue);
 
@@ -1134,7 +1134,7 @@ l_ldap_start_tls_s( LDAPObject* self, Py
     result = ldap_start_tls_s( self->ldap, NULL, NULL );
     if ( result != LDAP_SUCCESS ){
 	ldap_set_option(self->ldap, LDAP_OPT_ERROR_NUMBER, &result);
-	return LDAPerror( self->ldap, "ldap_start_tls_s" );
+	return LDAPerror( self->ldap, "ldap_start_tls_s", -1 );
     }
 
     Py_INCREF(Py_None);
@@ -1225,7 +1225,7 @@ l_ldap_passwd( LDAPObject* self, PyObjec
     LDAPControl_List_DEL( client_ldcs );
 
     if ( ldaperror!=LDAP_SUCCESS )
-    	return LDAPerror( self->ldap, "ldap_passwd" );
+    	return LDAPerror( self->ldap, "ldap_passwd", -1 );
 
     return PyInt_FromLong( msgid );
 }
Only in python-ldap/Modules: LDAPObject.c.orig
Only in python-ldap/Modules: LDAPObject.c.rej
diff -urwp python-ldap.TLS_PROTOCOL_MIN/Modules/message.c python-ldap/Modules/message.c
--- python-ldap.TLS_PROTOCOL_MIN/Modules/message.c	2009-08-16 21:49:47.000000000 -0400
+++ python-ldap/Modules/message.c	2009-10-22 13:15:40.000000000 -0400
@@ -24,12 +24,14 @@ LDAPmessage_to_python(LDAP *ld, LDAPMess
 
      PyObject* result;
      LDAPMessage* entry;
+     int msgid;
 
      result = PyList_New(0);
      if (result == NULL) {
         ldap_msgfree( m );
 	return NULL;
      }
+     msgid = ldap_msgid(m);
 
      for(entry = ldap_first_entry(ld,m);
          entry != NULL;
@@ -45,7 +47,7 @@ LDAPmessage_to_python(LDAP *ld, LDAPMess
 	 if (dn == NULL)  {
 	     Py_DECREF(result);
              ldap_msgfree( m );
-	     return LDAPerror( ld, "ldap_get_dn" );
+	     return LDAPerror( ld, "ldap_get_dn", msgid );
 	 }
 
 	 attrdict = PyDict_New();
@@ -138,7 +140,7 @@ LDAPmessage_to_python(LDAP *ld, LDAPMess
 	 if (ldap_parse_reference(ld, entry, &refs, NULL, 0) != LDAP_SUCCESS) {
 	     Py_DECREF(result);
 	     ldap_msgfree( m );
-	     return LDAPerror( ld, "ldap_parse_reference" );
+	     return LDAPerror( ld, "ldap_parse_reference", msgid );
 	 }
 	 if (refs) {
 	     Py_ssize_t i;
Only in python-ldap/Modules: message.c.orig
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Python-LDAP-dev mailing list
Python-LDAP-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/python-ldap-dev

Reply via email to