Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Capturing LDAP error message
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rick Sanders  
View profile  
 More options Jul 19 2011, 11:17 am
Newsgroups: perl.ldap
From: rfs9...@earthlink.net (Rick Sanders)
Date: Tue, 19 Jul 2011 10:17:27 -0500
Local: Tues, Jul 19 2011 11:17 am
Subject: Capturing LDAP error message
I am trying to capture a better error description than I am getting with
the following code:

use Net::LDAP::Util qw(ldap_error_name ldap_error_text ldap_error_desc);

$result = $ldap->add( $dn, attr => [ %$attrs ] );
if ( $result->code ) {
    $error = $result->code;
    $errtxt = ldap_error_name( $result->code );
    Log("      ERROR adding $dn: $errtxt");
    $errtxt = ldap_error_text( $result->code );
    Log("      ERROR adding $dn: $errtxt");
    $errtxt = ldap_error_desc( $result->code );
    Log("      ERROR adding $dn: $errtxt");

}

That gives me the following:

       ERROR adding mail=MILLENNIUMTENS,o=site: LDAP_INVALID_SYNTAX
       ERROR adding mail=MILLENNIUMTENS,o=site: Some part of the request
contained an invalid syntax. It could be a search with an invalid filter
or a request to modify the schema and the given schema has a bad syntax.
       ERROR adding mail=MILLENNIUMTENS,o=site: Invalid syntax

If I set $ldap->debug(12) then a ton of info is written to STDERR that
contains the details I need (showing the value that caused the error).

Net::LDAP=HASH(0x2993f4) received:
0000 30   86: SEQUENCE {
0002 02    1:   INTEGER = 5
0005 69   81:   [APPLICATION 9] {
0007 0A    1:     ENUM = 21
000A 04    0:     STRING = ''
000C 04   74:     STRING = 'Bad SMTP Address; not canonical form,
Attribute=mail, Value=MILLENNIUMTENS'
0058        :   }
0058        : }

Is there a way in NET::LDAP to grab that error string other than
redirecting STDERR and parsing it?  "LDAP_INVALID_SYNTAX" is not
particularly helpful in diagnosing why the syntax was invalid.

Thanks,
Rick


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.