Error in ldap->add

Discussion in 'Perl Misc' started by neelesh@netyantra.com, May 27, 2004.

  1. Guest

    Hi....
    I am using perl with open LDAP over linux and i am getting error of
    invalid dn when i use following statement.....

    $result = $ldap->add(dn =>'$dn', attr => [$attr]);

    where $dn and $attr are variable but when i use following statement
    then code succcessfully runs

    $result = $ldap->add(dn => 'pidTable=test,dc=nycube',attr =>['pid'
    => 'test','objectClass' => 'pidTable','userid' => ['testing'],]);

    here $str is constructed by concatenation of $key=>$value pair i want
    to use this method because each time when i am calling this function
    then passed no of arguments may be different so i construct string by
    concatenation of $key=>$value pair and then i passed it to this
    function.
    so i want to ask why this error is generating.Is there any possibility
    inthe case of earlier ldap->add statment that variableds inside the
    parentheses are not interpreted before the execution of ldap->add
    statement and can i use this statement
    $result = $ldap->add(dn =>'$dn', attr => [$attr]);

    reply me as soon as possible.
    Thanks,
    Neelesh Vijaivargia
    , May 27, 2004
    #1
    1. Advertising

  2. Paul Lalli Guest

    On Thu, 27 May 2004 wrote:

    > Hi....
    > I am using perl with open LDAP over linux and i am getting error of
    > invalid dn when i use following statement.....
    >
    > $result = $ldap->add(dn =>'$dn', attr => [$attr]);


    The dn is invalid because you are giving a value of the literal string
    '$dn'. That is, the string of a dollar sign, the letter 'd', and the
    letter 'n'.

    Change it to
    dn => "$dn"
    or even better
    dn => $dn

    The problem is that single quoted strings do not undergo variable
    interpolation - that is, variable names within ' ' do not expand to their
    contents.

    Paul Lalli
    Paul Lalli, May 27, 2004
    #2
    1. Advertising

  3. Keith Keller Guest

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2004-05-27, <> wrote:
    > Hi....
    > I am using perl with open LDAP over linux and i am getting error of
    > invalid dn when i use following statement.....
    >
    > $result = $ldap->add(dn =>'$dn', attr => [$attr]);


    Is the string $dn a valid DN for your LDAP server? Because that's
    what your single quotes are doing. Try

    $result = $ldap->add(dn =>"$dn", attr => [$attr]);

    or even

    $result = $ldap->add(dn => $dn , attr => [$attr]);

    - --keith

    - --
    -francisco.ca.us
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.3 (GNU/Linux)

    iD8DBQFAtgnehVcNCxZ5ID8RAsvGAJ9cf3IwEFGCOoqvNaOf07NOHE9VRgCeMGaJ
    14Tkbo/09+1FpoBs6Nw6hAw=
    =ocim
    -----END PGP SIGNATURE-----
    Keith Keller, May 27, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    527
    Raymond DeCampo
    Feb 21, 2006
  2. rcmn
    Replies:
    1
    Views:
    333
    =?ISO-8859-1?Q?Michael_Str=F6der?=
    Nov 6, 2006
  3. Jason Wold

    using LDAP Controls in ruby-ldap

    Jason Wold, Nov 4, 2004, in forum: Ruby
    Replies:
    5
    Views:
    241
  4. Ian Macdonald
    Replies:
    0
    Views:
    216
    Ian Macdonald
    Mar 15, 2005
  5. James Hughes
    Replies:
    4
    Views:
    325
    James Hughes
    Dec 13, 2005
Loading...

Share This Page