Newsgroups: perl.ldap Path: g2news1.google.com!news1.google.com!news3.google.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!195.71.90.67.MISMATCH!news.unit0.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!nntp.develooper.com!nntp.perl.org Return-Path: Mailing-List: contact perl-ldap-h...@perl.org; run by ezmlm Delivered-To: mailing list perl-l...@perl.org Received: (qmail 12202 invoked from network); 19 Jul 2011 15:17:26 -0000 Received: from x1.develooper.com (207.171.7.70) by x6.develooper.com with SMTP; 19 Jul 2011 15:17:26 -0000 Received: (qmail 29558 invoked by uid 225); 19 Jul 2011 15:17:26 -0000 Delivered-To: perl-l...@perl.org Received: (qmail 29553 invoked by alias); 19 Jul 2011 15:17:25 -0000 X-Spam-Status: No, hits=-0.1 required=8.0 tests=DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD X-Spam-Check-By: la.mx.develooper.com Received: from elasmtp-masked.atl.sa.earthlink.net (HELO elasmtp-masked.atl.sa.earthlink.net) (209.86.89.68) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Tue, 19 Jul 2011 08:17:24 -0700 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=dk20050327; d=earthlink.net; b=ghT/gItQmCXAIVX430JA4nGdd6ata3/b2jZGCBNpwEorxgSa4eKzOl07owtKnna1; h=Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding:X-ELNK-Trace:X-Originating-IP; Received: from [76.1.77.4] (helo=[192.168.1.101]) by elasmtp-masked.atl.sa.earthlink.net with esmtpa (Exim 4.67) (envelope-from ) id 1QjC2y-0004UM-6j; Tue, 19 Jul 2011 11:17:20 -0400 Message-ID: <4E25A007.3050000@earthlink.net> Date: Tue, 19 Jul 2011 10:17:27 -0500 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 Thunderbird/3.1.11 MIME-Version: 1.0 To: "perl-l...@perl.org" Subject: Capturing LDAP error message References: <9BB10F2F7016FF4DBB1993531D74D56C473A78DD53@DSM-EX01.dsm.net> <99A1CAF0-0BA8-40C5-9665-1DF5D0D0A1BD@pobox.com> <9BB10F2F7016FF4DBB1993531D74D56C473A78DD57@DSM-EX01.dsm.net> <256596A9-98B5-435B-B089-ACFBB4C70...@pobox.com> In-Reply-To: <256596A9-98B5-435B-B089-ACFBB4C70...@pobox.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ELNK-Trace: c21f53f5a20c6bc7d780f4a490ca6956d5d4673fe7faad86ede643da8a53d804fb52e211bbb26a61350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c X-Originating-IP: 76.1.77.4 Approved: n...@nntp.perl.org From: rfs9...@earthlink.net (Rick Sanders) 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