Hi

>I will join the lists, but the changes were made without any careful study
>of the program!  Give me a chance to recompile from scratch and I'll send
>what I have.


Ok.  I have recompiled Net-LDAPapi with OpenLDAP patches and also with Perl
5.6

The openldap-dif file attached was sent to me by Howard Chu to patch for
OpenLDAP 2.0.  I had to adjust it somewhat to get it to work, but it works
for all files (with some fuzz on test.pl) in Net-LDAPapi-1.42.

For Perl 5.6 you have to make some changes in LDAPapi.xs:
  search and replace all ",na)" with ",PL_na"
  replace "&sv_undef" with "&PL_sv_undef"

The diff file for this is also included (ldapapixs.txt).

A caveat: please note that I am a new user of this program and new to this
list, so can't offer any guarantees.
I am still having some problems with the working system but these are (I
believe) due to not having a certificate in
my browser.

Tim
Index: Changes
===================================================================
RCS file: /var/CVSROOT/pldap/Changes,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: Credits
===================================================================
RCS file: /var/CVSROOT/pldap/Credits,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: LDAPapi.pm
===================================================================
RCS file: /var/CVSROOT/pldap/LDAPapi.pm,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- LDAPapi.pm  1998/06/12 18:48:07     1.1
+++ LDAPapi.pm  2000/04/25 23:14:46     1.3
@@ -216,6 +216,7 @@
    if (($status = ldap_abandon($self->{"ld"},$msgid)) != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -241,6 +242,7 @@
    if (($msgid = ldap_add($self->{"ld"},$dn,$mod)) < 0)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $msgid;
 }
@@ -266,6 +268,7 @@
    if (($status = ldap_add_s($self->{"ld"},$dn,$mod)) != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -287,6 +290,7 @@
    if ($msgid < 0)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return($msgid);
 }
@@ -308,6 +312,7 @@
    if ($status != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -331,6 +336,7 @@
    if ($msgid < 0)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return($msgid);
 }
@@ -353,6 +359,7 @@
       != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -390,6 +397,7 @@
    if ($msgid < 0)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return($msgid);
 }
@@ -410,6 +418,7 @@
    if (($status = ldap_delete_s($self->{"ld"},$dn)) != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -630,6 +639,7 @@
    if ($msgid < 0)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $msgid;
 }
@@ -655,6 +665,7 @@
    if (($status = ldap_modify_s($self->{"ld"},$dn,$mod)) != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -670,6 +681,7 @@
    if ($msgid < 0)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $msgid;
 }
@@ -686,6 +698,7 @@
    if ($status != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -759,6 +772,7 @@
    if (($msgid = ldap_url_search($self->{"ld"},$url,$attrsonly)) < 0)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $msgid;
 }
@@ -775,6 +789,7 @@
       $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    $self->{"result"} = $result;
    return $status;
@@ -792,6 +807,7 @@
       $result)) != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    $self->{"result"} = $result;
    return $status;
@@ -813,6 +829,7 @@
    if ($status != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -833,6 +850,7 @@
    if ($status != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return $status;
 }
@@ -856,6 +874,7 @@
    if ($msgid < 0)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    return($msgid);
 }
@@ -879,6 +898,7 @@
    if ($status != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
    }
    $self->{"result"} = $result;
    return $status;
@@ -903,6 +923,7 @@
    if ($status != $self->LDAP_SUCCESS)
    {
       $self->{"errno"} = ldap_get_lderrno($self->{"ld"},$errdn,$extramsg);
+      $self->{"extramsg"} = $extramsg;
       $self->{"errstring"} = ldap_err2string($self->{"errno"});
    }
    $self->{"result"} = $result;
@@ -1013,6 +1034,12 @@
 {
    my ($self) = @_;
    return ldap_err2string($self->{"errno"});
+}
+
+sub extramsg
+{
+   my ($self) = @_;
+   return $self->{"extramsg"};
 }
 
 sub ld
Index: LDAPapi.xs
===================================================================
RCS file: /var/CVSROOT/pldap/LDAPapi.xs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LDAPapi.xs  1998/06/12 18:37:14     1.1
+++ LDAPapi.xs  2000/02/10 00:30:14     1.2
@@ -362,7 +362,7 @@
        OUTPUT:
        RETVAL
 
-#ifdef NETSCAPE_LDAP
+#if defined(NETSCAPE_LDAP) || defined(OPENLDAP)
 
 int
 ldap_set_option(ld,option,optdata)
@@ -726,7 +726,7 @@
        BerElement *ber
        int freebuf
 
-#ifdef NETSCAPE_LDAP
+#if defined(NETSCAPE_LDAP) || defined(OPENLDAP)
 
 int
 ldap_msgid(lm)
@@ -736,7 +736,33 @@
 ldap_msgtype(lm)
        LDAPMessage *   lm
 
+#else
+
+int
+ldap_msgid(lm)
+       LDAPMessage *   lm
+       CODE:
+       {
+          RETVAL = lm->lm_msgid;
+       }
+       OUTPUT:
+       RETVAL
+
 int
+ldap_msgtype(lm)
+       LDAPMessage *   lm
+       CODE:
+       {
+          RETVAL = lm->lm_msgtype;
+       }
+       OUTPUT:
+       RETVAL
+
+#endif
+
+#if defined(NETSCAPE_LDAP)
+
+int
 ldap_get_lderrno(ld,m,s)
        LDAP *          ld
        char *          m = NO_INIT
@@ -760,35 +786,21 @@
 #else
 
 int
-ldap_msgid(lm)
-       LDAPMessage *   lm
-       CODE:
-       {
-          RETVAL = lm->lm_msgid;
-       }
-       OUTPUT:
-       RETVAL
-
-int
-ldap_msgtype(lm)
-       LDAPMessage *   lm
-       CODE:
-       {
-          RETVAL = lm->lm_msgtype;
-       }
-       OUTPUT:
-       RETVAL
-
-int
 ldap_get_lderrno(ld,m,s)
        LDAP *          ld
        char *          m = NO_INIT
        char *          s = NO_INIT
        CODE:
        {
+#ifdef OPENLDAP
+          ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &RETVAL);
+          ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &s);
+          ldap_get_option(ld, LDAP_OPT_MATCHED_DN, &m);
+#else
           RETVAL = ld->ld_errno;
           m = ld->ld_matched;
           s = ld->ld_error;
+#endif
        }
        OUTPUT:
        RETVAL
@@ -804,9 +816,15 @@
        CODE:
        {
           RETVAL = 0;
+#ifdef OPENLDAP
+          ldap_set_option(ld, LDAP_OPT_ERROR_NUMBER, &e);
+          ldap_set_option(ld, LDAP_OPT_ERROR_STRING, s);
+          ldap_set_option(ld, LDAP_OPT_MATCHED_DN, m);
+#else
           ld->ld_errno = e;
           ld->ld_matched = m;
           ld->ld_error = s;
+#endif
        }
        OUTPUT:
        RETVAL
Index: MANIFEST
===================================================================
RCS file: /var/CVSROOT/pldap/MANIFEST,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: Makefile.PL
===================================================================
RCS file: /var/CVSROOT/pldap/Makefile.PL,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.PL 1998/06/12 18:53:26     1.1
+++ Makefile.PL 2000/02/10 00:30:14     1.2
@@ -1,7 +1,6 @@
 use ExtUtils::MakeMaker;
 use Config;
 
-
 print "\n\nNet::LDAPapi Perl5 Module - by Clayton Donley 
<donley\@cig.mcel.mot.com>\n\n";
 
 $pl_path = $Config{'perlpath'};
@@ -12,12 +11,14 @@
    print "  1.  Netscape (default)\n";
    print "  2.  University of Michigan\n";
    print "  3.  ISODE (compiled with LDAP)\n";
+   print "  4.  OpenLDAP\n";
    print "Choose: ";
    $sdk = <>;
 }
 
 $version = ($sdk == 2 ? 'UMICH' :
            $sdk == 3 ? 'ISODE' :
+           $sdk == 4 ? 'OPENLDAP' :
            'NETSCAPE');
 
 $lname = ($version eq 'ISODE' ? 'ISODE' : 'LDAP');
@@ -47,7 +48,6 @@
    }
 }
 
-
 if ($lib_ldap eq "")
 {
    $df_lib = ($include_ldap =~ m%^(\S+)/include% ? "$1/lib" : "/usr/lib");
@@ -66,7 +66,6 @@
    }
 }
 
-
 if ($version eq "NETSCAPE")
 {
    print "Using Netscape's NEW LDAPv3 Development Kit (default: n)? ";
@@ -95,6 +94,22 @@
    }
 }
 
+if ($version eq "OPENLDAP")
+{
+    if ($^O eq "MSWin32")
+    {
+       $ldap_libs = 'ldap.lib lber.lib';
+    }
+    else
+    {
+       $ldap_libs = '-lldap -llber';
+
+       print "Include SSL libraries (default: n)? ";
+       $usessl = <>;
+       $ldap_libs .= ' -lssl -lcrypto' if ($usessl =~ /y.*/i)
+    }
+}
+
 sub MY::postamble
 {
     "
@@ -117,6 +132,9 @@
        ) : $version eq "ISODE" ? (
        'LIBS'          =>      ["-L$lib_ldap -lldap -llber -lisode"],
        'DEFINE'        =>      '-DISODE_LDAP',
+       ) : $version eq "OPENLDAP" ? (
+       'LIBS'          =>      ["-L$lib_ldap $ldap_libs"],
+       'DEFINE'        =>      '-DOPENLDAP',
        ) : (
        'LIBS'          =>      ["-L$lib_ldap -lldap -llber $kerblibs"],
        'DEFINE'        =>      '-Dbool=char -DHAS_BOOL',
Index: Manpage.old
===================================================================
RCS file: /var/CVSROOT/pldap/Manpage.old,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: README
===================================================================
RCS file: /var/CVSROOT/pldap/README,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: Todo
===================================================================
RCS file: /var/CVSROOT/pldap/Todo,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: constant.gen
===================================================================
RCS file: /var/CVSROOT/pldap/constant.gen,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: ldap_compat.h
===================================================================
RCS file: /var/CVSROOT/pldap/ldap_compat.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ldap_compat.h       1998/04/26 03:22:49     1.1
+++ ldap_compat.h       2000/02/10 00:30:14     1.2
@@ -11,6 +11,20 @@
 # define ber_free(x,y) Safefree(x)
 #endif
 
+/*
+ * OpenLDAP already defines these macros, so they must be #undef'd before
+ * they can be redefined.
+ */
+
+#ifdef OPENLDAP
+#undef LDAP_OPT_DEREF
+#undef LDAP_OPT_SIZELIMIT
+#undef LDAP_OPT_TIMELIMIT
+#undef LDAP_OPT_REFERRALS
+#undef LDAP_OPT_ON
+#undef LDAP_OPT_OFF
+#endif
+
 #define LDAP_OPT_DEREF 2
 #define LDAP_OPT_SIZELIMIT 3
 #define LDAP_OPT_TIMELIMIT 4
Index: test.pl
===================================================================
RCS file: /var/CVSROOT/pldap/test.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- test.pl     1998/06/12 18:38:30     1.1
+++ test.pl     2000/02/10 00:30:14     1.2
@@ -35,7 +37,7 @@
 ##  Initialize LDAP Connection
 ##
 
-if (($ld = new Net::LDAPapi(-host=>$ldap_host)) == -1)
+if (($ld = new Net::LDAPapi(-host=>$ldap_host,-port=>$ldap_port)) == -1)
 {
    print "open     - not ok\n";
    exit -1; 
Index: examples/ldapwalk.pl
===================================================================
RCS file: /var/CVSROOT/pldap/examples/ldapwalk.pl,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: examples/ldapwalk2.pl
===================================================================
RCS file: /var/CVSROOT/pldap/examples/ldapwalk2.pl,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: examples/testurl.pl
===================================================================
RCS file: /var/CVSROOT/pldap/examples/testurl.pl,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: examples/testwrite.pl
===================================================================
RCS file: /var/CVSROOT/pldap/examples/testwrite.pl,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: examples/updatepw.pl
===================================================================
RCS file: /var/CVSROOT/pldap/examples/updatepw.pl,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: examples/web500.pl
===================================================================
RCS file: /var/CVSROOT/pldap/examples/web500.pl,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
Index: examples/www-ldap.pl
===================================================================
RCS file: /var/CVSROOT/pldap/examples/www-ldap.pl,v
retrieving revision 1.1
retrieving revision 1.1.1.1
diff -u -r1.1 -r1.1.1.1
*** ../Net-LDAP-patched/LDAPapi.xs      Sat Mar 24 18:37:35 2001
--- LDAPapi.xs  Sat Mar 24 18:54:43 2001
***************
*** 8,14 ****
  }
  #endif
  
- 
  #include <lber.h>
  #include <ldap.h>
  
--- 8,13 ----
***************
*** 93,99 ****
        ldap_value_count++)
     {
        ldap_current_value_sv = av_fetch(ldap_value_array_av,ldap_value_count,0);
!       ldap_current_value_char = SvPV(*ldap_current_value_sv,PL_na);
        ldap_pvlen = SvCUR(*ldap_current_value_sv);
        if (strcmp(ldap_current_value_char,"") != 0)
        {
--- 92,98 ----
        ldap_value_count++)
     {
        ldap_current_value_sv = av_fetch(ldap_value_array_av,ldap_value_count,0);
!       ldap_current_value_char = SvPV(*ldap_current_value_sv,na);
        ldap_pvlen = SvCUR(*ldap_current_value_sv);
        if (strcmp(ldap_current_value_char,"") != 0)
        {
***************
*** 195,201 ****
        }
       }
     } else {
!       if (strcmp(SvPV(ldap_value_ref,PL_na),"") == 0)
        {
           if (ldap_add_func != 1)
           {
--- 194,200 ----
        }
       }
     } else {
!       if (strcmp(SvPV(ldap_value_ref,na),"") == 0)
        {
           if (ldap_add_func != 1)
           {
***************
*** 212,218 ****
            ldap_current_mod->mod_op = LDAP_MOD_REPLACE;
           }
           New(1,ldap_current_mod->mod_values,2,char *);
!        ldap_current_mod->mod_values[0] = SvPV(ldap_value_ref,PL_na);
         ldap_current_mod->mod_values[1] = NULL;
        }
     }
--- 211,217 ----
            ldap_current_mod->mod_op = LDAP_MOD_REPLACE;
           }
           New(1,ldap_current_mod->mod_values,2,char *);
!        ldap_current_mod->mod_values[0] = SvPV(ldap_value_ref,na);
         ldap_current_mod->mod_values[1] = NULL;
        }
     }
***************
*** 576,582 ****
              for (count=0;count <= arraylen; count++)
              {
                 current = av_fetch((AV *)SvRV(attrs),count,0);
!                attrs_char[count] = SvPV(*current,PL_na);
              }
              attrs_char[arraylen+1] = NULL;
           }
--- 575,581 ----
              for (count=0;count <= arraylen; count++)
              {
                 current = av_fetch((AV *)SvRV(attrs),count,0);
!                attrs_char[count] = SvPV(*current,na);
              }
              attrs_char[arraylen+1] = NULL;
           }
***************
*** 612,618 ****
                 for (count=0;count <= arraylen; count++)
                 {
                    current = av_fetch((AV *)SvRV(attrs),count,0);
!                   attrs_char[count] = SvPV(*current,PL_na);
                 }
                 attrs_char[arraylen+1] = NULL;
              }
--- 611,617 ----
                 for (count=0;count <= arraylen; count++)
                 {
                    current = av_fetch((AV *)SvRV(attrs),count,0);
!                   attrs_char[count] = SvPV(*current,na);
                 }
                 attrs_char[arraylen+1] = NULL;
              }
***************
*** 658,664 ****
              for (count=0;count <= arraylen; count++)
              {
                 current = av_fetch((AV *)SvRV(attrs),count,0);
!                attrs_char[count] = SvPV(*current,PL_na);
              }
              attrs_char[arraylen+1] = NULL;
           }
--- 657,663 ----
              for (count=0;count <= arraylen; count++)
              {
                 current = av_fetch((AV *)SvRV(attrs),count,0);
!                attrs_char[count] = SvPV(*current,na);
              }
              attrs_char[arraylen+1] = NULL;
           }
***************
*** 1153,1159 ****
  #endif
              ldap_free_urldesc(realcomp);
           } else {
!             RETVAL = &PL_sv_undef;
           }
        }
        OUTPUT:
--- 1152,1158 ----
  #endif
              ldap_free_urldesc(realcomp);
           } else {
!             RETVAL = &sv_undef;
           }
        }
        OUTPUT:
***************
*** 1237,1243 ****
                   for (count=0;count <= arraylen; count++)
                   {
                      current = av_fetch((AV *)SvRV(attrs),count,0);
!                     attrs_char[count] = SvPV(*current,PL_na);
                   }
                   attrs_char[arraylen+1] = NULL;
                }
--- 1236,1242 ----
                   for (count=0;count <= arraylen; count++)
                   {
                      current = av_fetch((AV *)SvRV(attrs),count,0);
!                     attrs_char[count] = SvPV(*current,na);
                   }
                   attrs_char[arraylen+1] = NULL;
                }

Reply via email to