Skip to content

Instantly share code, notes, and snippets.

@rafaelfoster
Last active August 29, 2015 13:59
Show Gist options
  • Save rafaelfoster/10766280 to your computer and use it in GitHub Desktop.
Save rafaelfoster/10766280 to your computer and use it in GitHub Desktop.
OCS Inventory NG | OCS Reports
<?php
if ($_SESSION['OCS']['cnx_origine'] == "LOCAL"){
$name_field[]="PASSWORD";
$type_field[]=4; // Changed from '0' to '4' to mask the input field
$tab_name[]=$l->g(217).":";
$value_field[]=$protectedPost['PASSWORD'];
}
<?php
function ldap_test_pw($dn, $pw) {
$ds = ldap_connection ();
if (!$ds or !$pw) { // avec ldap 2.x.x, ldap_connect est tjrs ok. La connection n'est ouverte qu'au bind
return false;
} else {
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$r = ldap_bind($ds, $dn, $pw);
ldap_close($ds);
return $r;
}
}
function ldap_connection (){
if(!($ds = ldap_connect(LDAP_SERVEUR))) return false;
// $ds = ldap_connect(LDAP_SERVEUR,LDAP_PORT);
// Set the LDAP version
// add by acop http://forums.ocsinventory-ng.org/viewtopic.php?pid=35261
// ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, LDAP_PROTOCOL_VERSION);
ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
if (ROOT_DN != '' && defined('ROOT_DN')){
$b = ldap_bind($ds, ROOT_DN, ROOT_PW);
}else //Anonymous bind
$b = ldap_bind($ds);
if (!$b)
return false;
else
return $ds;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment