Skip to content

Commit

Permalink
use new method get_first_value from ltb-ldap project (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Coutadeur committed Jul 19, 2024
1 parent 6403e80 commit 3de4891
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"datatables.net/datatables.net-bs5": "2.0.8",
"datatables.net/datatables.net-buttons-bs5": "3.0.2",
"fortawesome/font-awesome": "v6.5.2",
"ltb-project/ltb-common": "v0.2.1",
"ltb-project/ltb-common": "dev-main",
"twbs/bootstrap": "v5.3.2"
},
"scripts": {
Expand Down
30 changes: 3 additions & 27 deletions lib/smarty.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

function get_attribute($params) {

$return = "";
$value = "";
$dn = $params["dn"];
$attribute = $params["attribute"];
$ldap_url = $params["ldap_url"];
Expand All @@ -27,35 +27,11 @@ function get_attribute($params) {
isset($ldap_krb5ccname) ? $ldap_krb5ccname : null
);

# Connect to LDAP
$ldap_connection = $ldapInstance->connect();

$ldap = $ldap_connection[0];
$result = $ldap_connection[1];
$value = $ldapInstance->get_first_value($dn, "base", $ldap_filter, $attribute);

if ($ldap) {

# Search entry
$search = ldap_read($ldap, $dn, $ldap_filter, explode(",", $attribute));

$errno = ldap_errno($ldap);

if ( $errno ) {
error_log("LDAP - Search error $errno (".ldap_error($ldap).")");
} else {
$entry = ldap_get_entries($ldap, $search);

# Loop over attribute
foreach ( explode(",", $attribute) as $ldap_attribute ) {
if ( isset ($entry[0][$ldap_attribute]) ) {
$return = $entry[0][$ldap_attribute][0];
break;
}
}
}
}

return $return;
return $value;
}

function convert_ldap_date($date) {
Expand Down

0 comments on commit 3de4891

Please sign in to comment.