-
my $mesg2 = $ldap->modify('$dn', replace =>{'userpassword'=> 'Test123' });
-
-
-
my $error = $mesg2->error;
-
print "\n############$dn \n############$error";
-
if($error == "Success")
-
{
-
print "\nPassword $error fully Changed";
-
}
-
else
-
{
-
print "\nCaught an exception: $error";
-
}
-
}
-
print "\n\n***************END OF OPERATION***************\n\n"
-
-
}
-
-
$ldap->unbind;
-
-
out put of line 5:
-
############uid=dphdlmk,ou=people,ou=associates,dc=albertsons,dc=com
-
############Invalid DN
-
-
After successfully binding the code with the LDAP server, I tried to run this code to change the password of the user in the LDAP server.
The problem is i that didn't know weather the password has been changed or not. To check this i have introduced a
if-else block. The flow of control is managed by the value of error variable, which should show "Success" in idle case. But when i print its value (see line 5), it shows the above stated output (see line 21).
Concern:
If we go with the output, then how is it possible that for a valid DN (as shown in line 22), the error variable is showing Invalid DN.
Secondly, Since the value of error variable is "Invalid DN" control should go to the else block, but it is going in the If block.
thanks in advance.
6 1653 RonB 589
Recognized Expert Moderator Contributor
== is a numerical test, it does not compare strings.
Change it to eq. -
if ($ent == "")
-
{
-
print "\nNo Match Found !!!\nPassword Cannot be changed";
-
}
-
else
-
{
-
my $dn=$ent->get_value('entrydn');
-
my $cn=$ent->get_value('cn');
-
print"\nOne Match Found !!!\nEmployee Name: $cn";
-
-
my $mesg2 = $ldap->modify('$dn', replace =>{'userpassword'=> 'Test123' });
-
-
my $error = $mesg2->error;
-
print "\n############$dn \n############$error";
-
-
if($error == "Success")
-
{
-
print "\nPassword $error fully Changed";
-
}
-
else
-
{
-
print "\nCaught an exception: $error";
-
}
-
}
-
print "\n\n***************END OF OPERATION***************\n\n"
-
Thanks for replying, RonB.I tried what u said, it worked for line 16.
But still i don't see this as an exact reason. As if it were true, then expression at line one also follow the same rule. If i compare that expression using '==' operator it always return false (ie. go to else part). irrespective of rvalue is string(i tried "" , " " and "anystring") or integer (i tried -1,0 and 1).
Moreover, do you have any idea about my first concern(from previous post) ? If we go with the output, then how is it possible that for a valid DN (as shown in line 22), the error variable is showing Invalid DN.
if you are comparing a variable to a sting, you should use 'eq' as already said. if comparing integers use '==' and if coparing against a null or empty value, I would use 'eq'
(Ignore the '' surrounding the operators).
bazz
RonB 589
Recognized Expert Moderator Contributor
Hi Bazz,
I see you're branching out.
Ron aka FishMonger
RonB 589
Recognized Expert Moderator Contributor - my $mesg2 = $ldap->modify('$dn', replace =>{'userpassword'=> 'Test123' });
Don't quote individual vars.
Since you're using single quotes around the $dn var, perl won't interpolate it. Instead, it sees it as the literal string $dn which is why you received the error message.
What a damn silly blunder it was. Feeling offended now. Sorry guys.
Thanks Bazz
Thanks RonB
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lee Redeem |
last post by:
Hi there
I've created abd uploaded this basic PHP script:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<H1 align="center">
|
by: Koen |
last post by:
Hi all,
I am experimenting with DAO. I wrote this sub to update one specific field
of one specific row in one specific table. Nothing wrong with the SQL
statement, but when I execute this I get...
|
by: Jeff Cooper |
last post by:
Hey Folks,
I have a bunch of aspx pages in a solution. One of these pages, call it
header1.aspx, has it's code behind in header1.aspx.vb. Another,
header2.aspx, has header2.aspx.vb. When I...
|
by: Polaris |
last post by:
Hi Experts:
The program creates Panels and inicilize them. When I run the code below,
the program crashes (at the line commented below). Any help is appriciated.
Thanks in Advance!
Polaris
...
|
by: Alvaro G. Vicario |
last post by:
The code below inserts a <spantag around the image. It works fine in
Firefox or Opera, but has a weird effect in Internet Explorer: browser
keeps loading the image forever... Even though the...
| |
by: =?GB2312?B?yum09MXt?= |
last post by:
today I forgot to include some header,then I found the error message by the compiler is quite strange.
so I want to know exactly the inner details of the compiler impletation,if possible.
and I...
|
by: canabatz |
last post by:
im using paging on this query:
i got this code that returning wrong results:
(SELECT bid_price, count(*) as n from bidding_details where bid_id=$bid_id GROUP BY bid_price DESC HAVING n = 1 ) ...
|
by: doudou88 |
last post by:
Hello,
I try to debug a c# program using mono-debugger. But i need first to create .exe.mdb file, using the folowing command:
gmcs -debug program.cs
When doing this I get the following error:...
|
by: muddasirmunir |
last post by:
I am trying to give the following Icon in my form in vb6.
http://www.mediafire.com/?ymzgkgyi50j
But , when I put this in my form I got error
"Invalid Picutre"
What wrong in it? How to add...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |