Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ldap_connect(3) [php man page]

LDAP_CONNECT(3) 							 1							   LDAP_CONNECT(3)

ldap_connect - Connect to an LDAP server

SYNOPSIS
resource ldap_connect NULL ([string $hostname], [int $port = 389]) DESCRIPTION
Establishes a connection to a LDAP server on a specified $hostname and $port. PARAMETERS
o $hostname - If you are using OpenLDAP 2.x.x you can specify a URL instead of the hostname. To use LDAP with SSL, compile OpenLDAP 2.x.x with SSL support, configure PHP with SSL, and set this parameter as ldaps://hostname/. o $port - The port to connect to. Not used when using URLs. RETURN VALUES
Returns a positive LDAP link identifier on success, or FALSE on error. When OpenLDAP 2.x.x is used, ldap_connect(3) will always return a resource as it does not actually connect but just initializes the connecting parameters. The actual connect happens with the next calls to ldap_* funcs, usually with ldap_bind(3). If no arguments are specified then the link identifier of the already opened link will be returned. EXAMPLES
Example #1 Example of connecting to LDAP server. <?php // LDAP variables $ldaphost = "ldap.example.com"; // your ldap servers $ldapport = 389; // your ldap server's port number // Connecting to LDAP $ldapconn = ldap_connect($ldaphost, $ldapport) or die("Could not connect to $ldaphost"); ?> Example #2 Example of connecting securely to LDAP server. <?php // make sure your host is the correct one // that you issued your secure certificate to $ldaphost = "ldaps://ldap.example.com/"; // Connecting to LDAP $ldapconn = ldap_connect($ldaphost) or die("Could not connect to {$ldaphost}"); ?> SEE ALSO
ldap_bind(3). PHP Documentation Group LDAP_CONNECT(3)

Check Out this Related Man Page

LDAP_COMPARE(3) 							 1							   LDAP_COMPARE(3)

ldap_compare - Compare value of attribute found in entry specified with DN

SYNOPSIS
mixed ldap_compare (resource $link_identifier, string $dn, string $attribute, string $value) DESCRIPTION
Compare $value of $attribute with value of same attribute in an LDAP directory entry. PARAMETERS
o $link_identifier - An LDAP link identifier, returned by ldap_connect(3). o $dn - The distinguished name of an LDAP entity. o $attribute - The attribute name. o $value - The compared value. RETURN VALUES
Returns TRUE if $value matches otherwise returns FALSE. Returns -1 on error. EXAMPLES
The following example demonstrates how to check whether or not given password matches the one defined in DN specified entry. Example #1 Complete example of password check <?php $ds=ldap_connect("localhost"); // assuming the LDAP server is on this host if ($ds) { // bind if (ldap_bind($ds)) { // prepare data $dn = "cn=Matti Meikku, ou=My Unit, o=My Company, c=FI"; $value = "secretpassword"; $attr = "password"; // compare value $r=ldap_compare($ds, $dn, $attr, $value); if ($r === -1) { echo "Error: " . ldap_error($ds); } elseif ($r === true) { echo "Password correct."; } elseif ($r === false) { echo "Wrong guess! Password incorrect."; } } else { echo "Unable to bind to LDAP server."; } ldap_close($ds); } else { echo "Unable to connect to LDAP server."; } ?> NOTES
Warning ldap_compare(3) can NOT be used to compare BINARY values! PHP Documentation Group LDAP_COMPARE(3)
Man Page

15 More Discussions You Might Find Interesting

1. Programming

Problem Connecting to Socket

Can anyone help? I'm trying to write a program which will write to a socket. I can get the server to run, but always get an error when I try to connect. It gives me an error at the "connect" command. It's probably a simple error, but I can't seem to find it. #include <sys/socket.h>... (6 Replies)
Discussion started by: Stevhp
6 Replies

2. UNIX for Dummies Questions & Answers

Connecting to SUN server from PC

I have old SUN server on my desk. I know it worked before. I want to be able to connect to server from my PC. Just to establish a dump terminal. 1. I connected to power socket 2. I Have a cable that fits in (i believe is a com ports there are A B slots the same I plugged it in A). They are... (33 Replies)
Discussion started by: zam
33 Replies

3. Solaris

port on solaris 10

when i connecting an usb device to a ubuntu box. i know its on /dev/ttyUSB0 port from dmesg. and i can do simple command with minicom connect to the port. however when i connecting the same usb device to solaris 10 platform and i do dmesg. i get Oct 31 14:50:02 karma usba: USB 1.10 device... (7 Replies)
Discussion started by: conandor
7 Replies

4. Solaris

T5240 netmgmt port not blinking

I was trying to configure the netmgmt from the serial and set commitpending to true. However, the netmgmt port is not up and blinking. I tried to connect using my notebook directly to the netmgmt port and am not able to ping as well. Previouly i was doing the firmware upgrade using the webconsole.... (20 Replies)
Discussion started by: incredible
20 Replies

5. Programming

To write C Script for connecting to a Server

Hi, I am little bit new to this scripting langauge as such, though I know the basics. I want to write a C script which connect to a server which is listening on tcp/ip via port number 6901 with username and password and then i have to call various services to test the server. Can some one help... (7 Replies)
Discussion started by: Nagesh
7 Replies

6. Solaris

LDAP problems

My boot-up software is giving me an error saying that it cannot connect to the ldap server and that the memory is full even though it's not. Does anyone know any ways around this? I heard there is something like a single user command, but how do you type this if you can't log in in the first place?... (5 Replies)
Discussion started by: solaris_newb
5 Replies

7. UNIX for Advanced & Expert Users

Different login shells in LDAP

Hi folks, we have a very heterogenous server environment. There are also lots of AIX and Linux servers which usually have different login shells and all servers have to be integrated into LDAP. The LDAP Meta Directory is hosted by a Novell eDirectory. On our Linux boxes it is usually bash, on... (5 Replies)
Discussion started by: zaxxon
5 Replies

8. Programming

Debugging IO::Socket Not Connecting

I'm using perl to connect to a port on a unix box from a windows machine. The unix box is located in a remote office and I'm able to connect just fine from my desktop at work across the network. But if I try to remote to another windows machine at the same location as the unix box and try to... (5 Replies)
Discussion started by: nwboy74
5 Replies

9. UNIX for Dummies Questions & Answers

Connect using ssh

Dear users I have a question about connecting to remote servers using terminal I can connect to one server by ssh username@domain_of_first_server.com and after logging into the above i have to connect to one more server ssh name_of_second_server bascically to be able to connect to the... (5 Replies)
Discussion started by: kevincobain2000
5 Replies

10. Solaris

Login issue

Hello, I'm trying to setup my Solaris 10 servers to authenticate from a OpenLDAP server. I can get the Linux servers to authenticate from a OpenLDAP server, but not server the Solaris servers. Below I have posted some output so you can see my issue. <terminal output> -bash-3.00$ id... (5 Replies)
Discussion started by: bitlord
5 Replies

11. Red Hat

Regarding connecting to internet from RHEL 5 server

Dear All, I have a RHEL 5 server of 64 bit . I have disabled the firewalls and added the name server also in resolv.conf. I want to connect to internet inorder to link the machine with Linux Network. # I could not connect to any website from this server for ex ping google.com is not... (8 Replies)
Discussion started by: jegaraman
8 Replies

12. Windows & DOS: Issues & Discussions

Connecting to UNIX from Windows without using putty

Hi Is there any command which we can try connecting unix from windows without using any third party tool. Thanks in advance KVB (9 Replies)
Discussion started by: bikky6
9 Replies

13. Solaris

LDAP Client not connecting to LDAP server

I have very limited knowledge on LDAP configuration and have been trying fix one issue, but unsuccessful. The server, I am working on, is Solaris-10 zone. sudoers is configured on LDAP (its not on local server). I have access to login directly on server with root, but somehow sudo is not working... (9 Replies)
Discussion started by: solaris_1977
9 Replies

14. UNIX for Beginners Questions & Answers

Red Hat: Error connecting using secure shell

Hi All, I am getting below error when I try to connect with ssh. Not sure why the error is on.I am able to connect from a different login from the same server (local: rhe/home/s3>) ssh acces1@91.1.12.102 Connection closed by 91.1.12.102 (local: rhe/home/s3>) ssh redhlinx102 Connection... (7 Replies)
Discussion started by: arunkumar_mca
7 Replies

15. AIX

IBM TDS/SDS (LDAP) - can I mix endianness among servers in an instance ?

I'd like to add some x/linux-based servers to my current AIX-based TDS/SDS server community. Reading the Fine Install Guide (rtfig ?) I believe this may be covered by the section "Upgrade an instance of a previous version to a different computer" i.e. I'm going to install latest/greatest SDS on a... (4 Replies)
Discussion started by: maraixadm
4 Replies