473,378 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

ldap_bind problem

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?

Here is the code.

//----------------------------------------------------------------
$myclient="usernamehere";
echo "<h3>LDAP query test</h3>";
echo "<B>Connecting ...</B><BR>";

$ds=ldap_connect("xxxxx.xxxxx.ac.uk"); // working address supplied
here...
echo "connect result is ".$ds."<p>";

if ($ds) {
echo "Binding ...(anon)...";
$r=ldap_bind($ds);
echo "Bind result is ".$r."<p>";

echo "Searching for <B>$myclient</B> ...";
// Search surname entry
$sr=ldap_search($ds,"OU=STAFF, OU=DS, OU=SEC, O=LINST",
"CN=$myclient");
echo "Search result is ".$sr."<p>";

echo "Number of entires returned is
".ldap_count_entries($ds,$sr)."<p>";

echo "Getting entries ...<p>";
$info = ldap_get_entries($ds, $sr);
echo "Data for ".$info["count"]." items returned:<p>";
echo "<HR>";

for ($i=0; $i<$info["count"]; $i++) {
echo "Full name (fullname) entry is: ".
$info[$i]["fullname"][0] ."<br>";
echo "Job title (title) entry is: ". $info[$i]["title"][0]
.."<br>";
echo "Common name (cn) entry is: ". $info[$i]["cn"][0]
.."<br>";
echo "E-mail (mail) entry is: ". $info[$i]["mail"][0] ."<br>";
echo "Telephone (telephonenumber) entry is: ".
$info[$i]["telephonenumber"][0]."<br>";
echo "Domain (dn) is: ". $info[$i]["dn"] ."<P><HR>\n";

echo printall($info[$i]);

}

echo "<P><B>Closing connection</B>";
ldap_close($ds);

} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}
//----------------------------------------------------------------

Any suggestions welcome.
Mike

May 23 '06 #1
1 2088

do******@gmail.com wrote:
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?

Here is the code.

//----------------------------------------------------------------
$myclient="usernamehere";
echo "<h3>LDAP query test</h3>";
echo "<B>Connecting ...</B><BR>";

$ds=ldap_connect("xxxxx.xxxxx.ac.uk"); // working address supplied
here...
echo "connect result is ".$ds."<p>";

if ($ds) {
echo "Binding ...(anon)...";
$r=ldap_bind($ds);
echo "Bind result is ".$r."<p>";

echo "Searching for <B>$myclient</B> ...";
// Search surname entry
$sr=ldap_search($ds,"OU=STAFF, OU=DS, OU=SEC, O=LINST",
"CN=$myclient");
echo "Search result is ".$sr."<p>";

echo "Number of entires returned is
".ldap_count_entries($ds,$sr)."<p>";

echo "Getting entries ...<p>";
$info = ldap_get_entries($ds, $sr);
echo "Data for ".$info["count"]." items returned:<p>";
echo "<HR>";

for ($i=0; $i<$info["count"]; $i++) {
echo "Full name (fullname) entry is: ".
$info[$i]["fullname"][0] ."<br>";
echo "Job title (title) entry is: ". $info[$i]["title"][0]
."<br>";
echo "Common name (cn) entry is: ". $info[$i]["cn"][0]
."<br>";
echo "E-mail (mail) entry is: ". $info[$i]["mail"][0] ."<br>";
echo "Telephone (telephonenumber) entry is: ".
$info[$i]["telephonenumber"][0]."<br>";
echo "Domain (dn) is: ". $info[$i]["dn"] ."<P><HR>\n";

echo printall($info[$i]);

}

echo "<P><B>Closing connection</B>";
ldap_close($ds);

} else {
echo "<h4>Unable to connect to LDAP server</h4>";
}
//----------------------------------------------------------------

Any suggestions welcome.
Mike


You can get the error or error number of the last command executed with
ldap_error() and ldap_errno(). See the following:

<http://www.php.net/ldap_error>
<http://www.php.net/ldap_errorno>

May 23 '06 #2

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

Similar topics

0
by: Bruce Davis | last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded tkinter gui application. The problem appears to be a deadlock condition when a child thread pops up a Pmw dialog window in...
11
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class...
117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
1
by: Max-B | last post by:
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...
3
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.