function ldap_lookup_uid($uid, $fields = null) { return ldap_lookup($uid, $fields); }
A few of the parameters for this function are currently stored in the redcap_config table... This probably isn't ideal and we should look into declaring a .properties file or something like that for storing per-installation specific values. Andy Martin Stanford University **/ // MAKE SURE redcap_confg CONTIANS stanford_ldap_url AND stanford_ldap_token; // Note: success just means the query returned - not that the result is a single valid user // Do a 'soft' match looking for anything that resembles the searched username // (such as email addresses or aliases in LDAP) // Our ldap_lookup returns an array like: // [ "count" => 2, // "1" => ["uid" => "andy123", "attribute1..n" => "value1..n"], // "2" => [...] // ] list($success, $ldap_result) = ldap_lookup($username, false); $msg = array(); // Array to hold messages // If the LDAP server is down or another error occurs, notify the user if (!$success) { // Deliver error message and exit $msg[] = "There was an error validating the specified SUNet ID (<b>{$username}</b>).<br/><br/>\n\t\t\tThis usually means the Stanford LDAP resource is not responding or another network error\n\t\t\thas occurred. Please back up and try again. If this error recurs, please send an email to\n\t\t\t<a href='mailto:redcap-help@lists.stanford.edu'>redcap-help@lists.stanford.edu</a> \n\t\t\tdescribing the problem.\n\t\t\t<hr><br>We apologize for the inconvenience and will do our best to resolve it promptly."; // Potentially notify a REDCap admin! with $ldap_result as a message return array('status' => FALSE, 'message' => implode('<br><br>', $msg)); } // Get number of results from LDAP search (included as first paramter from response) $count = $ldap_result['count']; // No match found if ($count === 0) { $msg[] = "The specified SUNet ID (<b>{$username}</b>) does not appear to be valid.<br/><br/>\n\t\tSome users have aliases so the prefix to their email address isn't necessarily the same as their\n\t\tSUNet ID. Try searching <a href='http://stanfordwho.stanford.edu/SWApp/authSearch.do?search={$username}' \n\t\ttarget='_BLANK'><b>Stanford Who</b></a> if you are unsure.<br><br>\n\t\tIf you are unable to locate your collaborator in Stanford Who, please contact them and request \n\t\ttheir correct SUNet ID."; return array('status' => FALSE, 'message' => implode('<br><br>', $msg));