summaryrefslogtreecommitdiff
path: root/ext/ldap
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ldap')
-rw-r--r--ext/ldap/ldap.c6
-rw-r--r--ext/ldap/php_ldap.h4
-rw-r--r--ext/ldap/tests/ldap_dn2ufn.phpt33
-rw-r--r--ext/ldap/tests/ldap_explode_dn.phpt94
-rw-r--r--ext/ldap/tests/skipif.inc5
5 files changed, 137 insertions, 5 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index f6e3c8739..eb70b483b 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -23,7 +23,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ldap.c,v 1.161.2.3.2.11 2007/07/17 09:09:42 jani Exp $ */
+/* $Id: ldap.c,v 1.161.2.3.2.12 2007/12/31 07:20:07 sebastian Exp $ */
#define IS_EXT_MODULE
#ifdef HAVE_CONFIG_H
@@ -322,7 +322,7 @@ PHP_MINFO_FUNCTION(ldap)
php_info_print_table_start();
php_info_print_table_row(2, "LDAP Support", "enabled");
- php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.161.2.3.2.11 2007/07/17 09:09:42 jani Exp $");
+ php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.161.2.3.2.12 2007/12/31 07:20:07 sebastian Exp $");
if (LDAPG(max_links) == -1) {
snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links));
diff --git a/ext/ldap/php_ldap.h b/ext/ldap/php_ldap.h
index 9b0627cf7..c401c3c28 100644
--- a/ext/ldap/php_ldap.h
+++ b/ext/ldap/php_ldap.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ldap.h,v 1.32.2.1.2.2 2007/07/13 01:24:16 jani Exp $ */
+/* $Id: php_ldap.h,v 1.32.2.1.2.3 2007/12/31 07:20:07 sebastian Exp $ */
#ifndef PHP_LDAP_H
#define PHP_LDAP_H
diff --git a/ext/ldap/tests/ldap_dn2ufn.phpt b/ext/ldap/tests/ldap_dn2ufn.phpt
new file mode 100644
index 000000000..50e4572d3
--- /dev/null
+++ b/ext/ldap/tests/ldap_dn2ufn.phpt
@@ -0,0 +1,33 @@
+--TEST--
+ldap_dn2ufn() test
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+/* Convert valid DN */
+var_dump(ldap_dn2ufn("cn=bob,dc=example,dc=com"));
+
+/* Convert valid DN */
+var_dump(ldap_dn2ufn("cn=bob,ou=users,dc=example,dc=com"));
+
+/* Convert DN with < > characters */
+var_dump(ldap_dn2ufn("cn=<bob>,dc=example,dc=com"));
+
+/* Too many parameters */
+ldap_dn2ufn("cn=bob,dc=example,dc=com", 1);
+
+/* Bad DN value */
+var_dump(ldap_dn2ufn("bob,dc=example,dc=com"));
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+string(16) "bob, example.com"
+string(23) "bob, users, example.com"
+bool(false)
+
+Warning: Wrong parameter count for ldap_dn2ufn() in %s on line %d
+bool(false)
+Done
diff --git a/ext/ldap/tests/ldap_explode_dn.phpt b/ext/ldap/tests/ldap_explode_dn.phpt
new file mode 100644
index 000000000..f713ca31f
--- /dev/null
+++ b/ext/ldap/tests/ldap_explode_dn.phpt
@@ -0,0 +1,94 @@
+--TEST--
+ldap_explode_dn() test
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+/* Explode with attributes */
+var_dump(ldap_explode_dn("cn=bob,dc=example,dc=com", 0));
+
+/* Explode with attributes */
+var_dump(ldap_explode_dn("cn=bob,ou=users,dc=example,dc=com", 0));
+
+/* Explode without attributes */
+var_dump(ldap_explode_dn("cn=bob,dc=example,dc=com", 1));
+
+/* Explode without attributes */
+var_dump(ldap_explode_dn("cn=bob,ou=users,dc=example,dc=com", 1));
+
+/* Explode with attributes and < > characters */
+var_dump(ldap_explode_dn("cn=<bob>,dc=example,dc=com", 0));
+
+/* Explode without attributes and < > characters */
+var_dump(ldap_explode_dn("cn=<bob>,dc=example,dc=com", 1));
+
+/* Too few parameters */
+ldap_explode_dn("cn=bob,dc=example,dc=com");
+
+/* Too many parameters */
+ldap_explode_dn("cn=bob,dc=example,dc=com", 1, 1);
+
+/* Bad DN value with attributes */
+var_dump(ldap_explode_dn("bob,dc=example,dc=com", 0));
+
+/* Bad DN value without attributes */
+var_dump(ldap_explode_dn("bob,dc=example,dc=com", 1));
+
+echo "Done\n";
+
+?>
+--EXPECTF--
+array(4) {
+ ["count"]=>
+ int(3)
+ [0]=>
+ string(6) "cn=bob"
+ [1]=>
+ string(10) "dc=example"
+ [2]=>
+ string(6) "dc=com"
+}
+array(5) {
+ ["count"]=>
+ int(4)
+ [0]=>
+ string(6) "cn=bob"
+ [1]=>
+ string(8) "ou=users"
+ [2]=>
+ string(10) "dc=example"
+ [3]=>
+ string(6) "dc=com"
+}
+array(4) {
+ ["count"]=>
+ int(3)
+ [0]=>
+ string(3) "bob"
+ [1]=>
+ string(7) "example"
+ [2]=>
+ string(3) "com"
+}
+array(5) {
+ ["count"]=>
+ int(4)
+ [0]=>
+ string(3) "bob"
+ [1]=>
+ string(5) "users"
+ [2]=>
+ string(7) "example"
+ [3]=>
+ string(3) "com"
+}
+bool(false)
+bool(false)
+
+Warning: Wrong parameter count for ldap_explode_dn() in %s on line %d
+
+Warning: Wrong parameter count for ldap_explode_dn() in %s on line %d
+bool(false)
+bool(false)
+Done
diff --git a/ext/ldap/tests/skipif.inc b/ext/ldap/tests/skipif.inc
new file mode 100644
index 000000000..d3494284b
--- /dev/null
+++ b/ext/ldap/tests/skipif.inc
@@ -0,0 +1,5 @@
+<?php
+if (!extension_loaded('ldap')){
+ die('skip ldap extension not available');
+}
+?>