Error in ldap->add

N

neelesh

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
 
P

Paul Lalli

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
 
K

Keith Keller

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

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

- --
(e-mail address removed)-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-----
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top