Created
October 21, 2014 17:42
-
-
Save blizzz/0b57f85c122dedf34da8 to your computer and use it in GitHub Desktop.
Tests whether the server specified by parameters supports Paged Results (RFC 2696)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if($argc < 4 || $argc === 5) { | |
print('Usage: php -f ' . $argv[0] . ' HOST PORT BASE [DN] [PWD]' . PHP_EOL); | |
die; | |
} | |
$host = $argv[1]; | |
$port = $argv[2]; | |
$host .= ':' . $port; | |
$base = $argv[3]; | |
$dn = $argc > 4 ? $argv[4] : ''; | |
$pwd = $argc > 4 ? $argv[5] : ''; | |
$cr = ldap_connect($host, $port); | |
ldap_set_option($cr, LDAP_OPT_PROTOCOL_VERSION, 3); | |
ldap_set_option($cr, LDAP_OPT_REFERRALS, 0); | |
ldap_bind($cr, $dn, $pwd); | |
$filter = '(|(uid=*)(samaccountname=*))'; | |
$attrs = array('cn', 'displayname'); | |
$cookie = ''; | |
ldap_control_paged_result($cr, 70, true, $cookie); | |
$sr = @ldap_search($cr, $base, $filter, $attrs); | |
if(is_resource($sr)) { | |
print("LDAP Server supports Paged Results" . PHP_EOL); | |
} else { | |
print("LDAP Server does not support Paged Results!!" . PHP_EOL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment