This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ben Sullins
committed
Apr 15, 2013
1 parent
5c5f3f0
commit 58c8f81
Showing
13 changed files
with
372 additions
and
128 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
require_once('init.php'); | ||
$ldap = get_ldap_connection(); | ||
include 'tableau_trusted.php'; | ||
|
||
if(add_tableau_user($_SERVER["PHP_AUTH_USER"], $_SERVER["PHP_AUTH_PW"], get_ldap_cn($_SERVER["PHP_AUTH_USER"]), 'interactor', 'none', '0')) { | ||
$trusted_url = login_tableau($_SERVER["PHP_AUTH_USER"],TABLEAU_SERVER,'projects'); | ||
echo '<meta http-equiv="refresh" content="2;url=' . $trusted_url . '">'; | ||
} else { | ||
echo "Failed attempt to create user: " . $_SERVER["PHP_AUTH_USER"]; | ||
} | ||
|
||
?> |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
require_once("init.php"); | ||
require_once("config.php"); | ||
require_once('templates/header.php'); | ||
|
||
|
||
$auth = new MozillaAuthAdapter(); | ||
$search = new MozillaSearchAdapter($ldapconn); | ||
|
||
function get_ldap_cn($user, $debug=0) { | ||
|
||
try{ | ||
|
||
if (!$ds = get_ldap_connection()) { throw new Exception('Unable to connect to LDAP Server');} | ||
$dn = "mail=$user, o=com, dc=mozilla"; //the object itself instead of the top search level as in ldap_search | ||
$filter="(objectclass=inetOrgPerson)"; // this command requires some filter | ||
$justthese = array("cn"); //the attributes to pull, which is much more efficient than pulling all attributes if you don't do this | ||
if (!$sr=ldap_read($ds, $dn, $filter, $justthese)) { throw new Exception('Incorrect Username or filter');} | ||
if (!$entry = ldap_get_entries($ds, $sr)) { throw new Exception('Unable to find LDAP entry for ' . $user);} | ||
|
||
if ($debug!=0) { | ||
echo $entry[0]["cn"][0] . " is the name in LDAP for " . $user; | ||
} | ||
|
||
ldap_close($ds); | ||
return $entry[0]["cn"][0]; | ||
|
||
} catch (Exception $e) { | ||
echo 'Oops! I countered the following error: ', $e->getMessage(), "\n"; | ||
} | ||
} | ||
|
||
get_ldap_cn("[email protected]"); | ||
|
||
require_once('templates/footer.php'); | ||
|
||
?> | ||
|
||
|
||
|
||
|
||
|
||
|
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
function output_json($entries) { | ||
header("Content-Type: application/json"); | ||
print json_encode($entries); | ||
die; | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
function get_attr_preprocessors() { | ||
return array( | ||
"employeetype" => "employee_status", | ||
"manager" => "get_manager", | ||
"mobile" => "mobile_normalizer", | ||
"im" => "mobile_normalizer" | ||
); | ||
} | ||
|
||
function employee_status($status) { | ||
global $orgs, $emp_type; | ||
$current_org = $current_emp_type = ""; | ||
if ($status != "") { | ||
$current_org = $status[0]; | ||
$current_emp_type = $status[1]; | ||
} | ||
if ($status == "DISABLED") { | ||
return array('DISABLED'); | ||
} else { | ||
if (array_key_exists($current_org, $orgs) && | ||
array_key_exists($current_emp_type, $emp_type)) { | ||
return array($orgs[$current_org], $emp_type[$current_emp_type]); | ||
} else { | ||
return array('Unknown'); | ||
} | ||
} | ||
} | ||
|
||
function get_manager($manager_dn) { | ||
global $ldapconn, $memcache_on, $memcache; | ||
if ($memcache_on && ($manager = $memcache->get(MEMCACHE_PREFIX . $manager_dn))) { | ||
return $manager; | ||
} | ||
$manager_search = @ldap_search($ldapconn, $manager_dn, '(mail=*)', array('cn','mail')); | ||
if (ldap_errno($ldapconn) == 32) { // No manager found | ||
return NULL; | ||
} | ||
if ($manager_search) { | ||
$entry = ldap_first_entry($ldapconn, $manager_search); | ||
if ($entry) { | ||
$attrs = ldap_get_attributes($ldapconn, $entry); | ||
$manager = array( | ||
"cn" => $attrs['cn'][0], | ||
"dn" => $manager_dn | ||
); | ||
} else { | ||
$manager = NULL; | ||
} | ||
if ($memcache_on) { | ||
$memcache->set(MEMCACHE_PREFIX . $manager_dn, $manager); | ||
} | ||
return $manager; | ||
} | ||
} | ||
|
||
function mobile_normalizer($m) { | ||
return is_array($m) ? $m : array($m); | ||
} | ||
|
||
function wikilinks($string) { | ||
$matches = array(); | ||
$string = nl2br(htmlspecialchars($string)); | ||
if (preg_match_all('/\[(.+?)(?:\s(.+?))?\]/', $string, $matches)) { | ||
foreach ($matches[1] as $key => $value) { | ||
if (!empty($matches[2][$key])) { | ||
$title = $matches[2][$key]; | ||
} else { | ||
$title = $value; | ||
} | ||
$string = str_replace( | ||
$matches[0][$key], | ||
'<a href="'. $value .'">'. $title .'</a>', | ||
$string | ||
); | ||
} | ||
} | ||
return $string; | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
require_once("init.php"); | ||
require_once("config.php"); | ||
require_once("preprocessors-attr.inc"); | ||
|
||
$auth = new MozillaAuthAdapter(); | ||
$search = new MozillaSearchAdapter($ldapconn); | ||
$keyword = isset($_GET["query"]) ? $_GET["query"] : $_SERVER["PHP_AUTH_USER"]; | ||
$entries = normalize($search->search_users($keyword)); | ||
$attr_preps = get_attr_preprocessors(); | ||
|
||
$preprocess_attr_functions = array(); | ||
foreach ($entries as &$entry) { | ||
foreach ($entry as $name => $attribute) { | ||
$prep = isset($attr_preps[$name]) ? $attr_preps[$name] : NULL; | ||
if (!isset($preprocess_attr_functions[$prep])) { | ||
$preprocess_attr_functions[$prep] = function_exists($prep); | ||
} | ||
if ($preprocess_attr_functions[$prep]) { | ||
$entry[$name] = call_user_func($prep, $attribute); | ||
} | ||
} | ||
$search->preprocess_entry($entry); | ||
} | ||
|
||
$format = isset($_GET["format"]) ? $_GET["format"] : "json"; | ||
if (!in_array($format, $output_formats) || !file_exists("output-$format.inc")) { | ||
$format = "json"; | ||
} | ||
require_once("output-$format.inc"); | ||
$function = "output_$format"; | ||
$dn = $auth->user_to_dn($_SERVER["PHP_AUTH_USER"]); | ||
call_user_func($function, $entries, $auth->is_phonebook_admin($ldapconn, $dn)); |
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