473,806 Members | 2,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ldap_bind warning instead of false

Hi,I wrote a very simple script to perform ldap authentication. Here is
a peace of code:
if ($ldapconn) {
// binding
$ldapbind = ldap_bind($ldap conn, $ldaprdn, $ldappass);

// verifica bind
if ($ldapbind) {
return true;
} else {
return false;
}
}

The script work quite well and if I insert a correct username and
password it returns me "true". The problem is that if the username or
password are wrong it returns me warning istead of "false".

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server:
Invalid credentials in /path/to/my/file.php on line 31

Warning: Cannot modify header information - headers already sent by
(output started at /path/to/my/file.php:31) in /path/to/my/file.php on
line 48

How can I obtain "false"?
ciao
--
Max-B

--------------------------------------------
Recensioni di ristoranti e opinioni libere
http://www.max-b.org
Feb 12 '07 #1
1 10223
Max-B wrote:
Hi,I wrote a very simple script to perform ldap authentication. Here
is a peace of code:
if ($ldapconn) {
// binding
$ldapbind = ldap_bind($ldap conn, $ldaprdn, $ldappass);

// verifica bind
if ($ldapbind) {
return true;
} else {
return false;
}
}

The script work quite well and if I insert a correct username and
password it returns me "true". The problem is that if the username or
password are wrong it returns me warning istead of "false".

Warning: ldap_bind() [function.ldap-bind]: Unable to bind to server:
Invalid credentials in /path/to/my/file.php on line 31

Warning: Cannot modify header information - headers already sent by
(output started at /path/to/my/file.php:31) in /path/to/my/file.php
on line 48

How can I obtain "false"?
ciao
You can get around this if you supress warning and error messages by
putting a @ in front of the function name:

$ldapbind = @ldap_bind($lda pconn, $ldaprdn, $ldappass);

--
Kim André Akerø
- ki******@NOSPAM betadome.com
(remove NOSPAM to contact me directly)
Feb 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

35
3230
by: jerrygarciuh | last post by:
Hi all, I was just wondering what popular opinion is on PHP giving this warning: Warning: Invalid argument supplied for foreach() in /home/boogerpic/public_html/my.php on line 6 when presented with an indefined variable. It makes sense to me to warn if an unacceptably defined var is passed but it
4
3843
by: myName | last post by:
Hi All, Getting warning in lint for this code. Any thought on this? Regards Ajay StcStackInterface::StcStackInterface() : genAlarm( false ), trace( false ),
6
3090
by: kermit | last post by:
I asp.net pages that run on an intranet IIS server. Some op the pages use XLM DOM doc.Load(sPath) to open and parse a XML file. Every time the doc.Load(sPath) executes in IE6 a warning message comes up "This page is accessing information that is not under it's control. . . " How can I avoid this message. It is a great anoyance to the users. Do I need to create some time of certificate to pass... Help! Need direction.
1
2095
by: Jazzkt | last post by:
I have a little issue I hope you can help me with. I retrieve the processes that are running on my computer and get the C4800 warning in certain situations. The code snippet below illustrates my challenge. Process* localAll = Process::GetProcesses(); printf("\nProcess name: %s",localAll->ProcessName); //works fine cout << "Process name: " << localAll->ProcessName << endl; //c4800
5
8092
by: Dmitriy Lapshin [C# / .NET MVP] | last post by:
Hi all, I think the VB .NET compiler should at least issue a warning when a function does not return value. C# and C++ compilers treat this situation as an error and I believe this is the right thing to do. And I wonder why VB .NET keeps silence and makes such function return some default value instead. Isn't it error-prone? -- Dmitriy Lapshin
1
6412
by: billa1972 | last post by:
Hi, I am trying to hook into Yellow Freight's rating webservice. Below is the wsdl. When i try and create a proxy file with wsdl.exe i get the following errors, see below. Also, when i reference this wsdl in .NET it seems to do it fine, yet there are no objects to reference except RateQuoteBeanService. In the WSDL it looks like there should be getRateQuote, and QUOTEREQUEST, etc.
1
2110
by: downlode | last post by:
Hi, I have a basic script for querying an ldap server. It works fine from my college's production server, but not from another server in the network, though I have been assured access should be allowed from there. It fails at the ldap_bind() function. This function only returns a boolean value. How might I retrieve a meaninful error message? Any ideas where the problem is likely to lie, with this basic info?
3
18727
by: eleland | last post by:
I am trying to bind to an LDAP server using php without success. I have a linux server running php compiled with open ldap. I am using the following code taken right from php.net: echo "<h3>LDAP query test</h3>"; echo "Connecting ..."; $ds=ldap_connect("ldap.berkeley.edu"); // must be a valid LDAP server! echo "connect result is ".$ds."<p>"; if ($ds) { echo "Binding ..."; $r=ldap_bind($ds); // this is an...
5
1639
by: Cubicle Intern | last post by:
Hi, I have a form with multiple fields that confirmed before the form is submitted (ex. email field needs to be completed before the form can be submitted). Once the required fields are completed, I want a final warning box to appear asking the user "are you sure you want to make these changes?" I'm having trouble getting the function to work correctly. Here's the problem I've encountered: First Script: this one lets me enter an...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
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 we have to send another system
3
3010
bsmnconsultancy
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.