468,284 Members | 1,476 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,284 developers. It's quick & easy.

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($ldapconn, $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 9418
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($ldapconn, $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($ldapconn, $ldaprdn, $ldappass);

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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by myName | last post: by
1 post views Thread by Jazzkt | last post: by
5 posts views Thread by Dmitriy Lapshin [C# / .NET MVP] | last post: by
1 post views Thread by billa1972 | last post: by
1 post views Thread by downlode | last post: by
5 posts views Thread by Cubicle Intern | last post: by
2 posts views Thread by MrBee | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.