1254 lines
301 KiB
HTML
1254 lines
301 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Code Coverage for /Volumes/Rest/Dev/Sites/authLDAP/authLdap.php</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="css/style.css" rel="stylesheet">
|
|
<!--[if lt IE 9]>
|
|
<script src="js/html5shiv.min.js"></script>
|
|
<script src="js/respond.min.js"></script>
|
|
<![endif]-->
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<ol class="breadcrumb">
|
|
<li><a href="index.html">/Volumes/Rest/Dev/Sites/authLDAP</a></li>
|
|
<li class="active">authLdap.php</li>
|
|
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
<div class="container">
|
|
<table class="table table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<td> </td>
|
|
<td colspan="10"><div align="center"><strong>Code Coverage</strong></div></td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td colspan="3"><div align="center"><strong>Classes and Traits</strong></div></td>
|
|
<td colspan="4"><div align="center"><strong>Functions and Methods</strong></div></td>
|
|
<td colspan="3"><div align="center"><strong>Lines</strong></div></td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="success">Total</td>
|
|
<td class="success big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100.00" aria-valuemin="0" aria-valuemax="100" style="width: 100.00%">
|
|
<span class="sr-only">100.00% covered (success)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="success small"><div align="right"></div></td>
|
|
<td class="success small"><div align="right">0 / 0</div></td>
|
|
<td class="success big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="100.00" aria-valuemin="0" aria-valuemax="100" style="width: 100.00%">
|
|
<span class="sr-only">100.00% covered (success)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="success small"><div align="right">100.00%</div></td>
|
|
<td class="success small"><div align="right">0 / 0</div></td>
|
|
<td class="success small"><abbr title="Change Risk Anti-Patterns (CRAP) Index">CRAP</abbr></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 476</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#13"><abbr title="authLdap_debug($message)">authLdap_debug</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 5</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#21"><abbr title="authLdap_addmenu()">authLdap_addmenu</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 5</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#28"><abbr title="authLdap_get_post($name, $default = '')">authLdap_get_post</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 3</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#33"><abbr title="authLdap_options_panel()">authLdap_options_panel</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 59</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#111"><abbr title="authLdap_get_server()">authLdap_get_server</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 10</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#149"><abbr title="authLdap_login($user, $username, $password, $already_md5 = false)">authLdap_login</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 177</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#405"><abbr title="authLdap_get_uid($username)">authLdap_get_uid</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 15</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#432"><abbr title="authLdap_user_role($uid)">authLdap_user_role</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 15</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#464"><abbr title="authLdap_groupmap($username, $dn)">authLdap_groupmap</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 47</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#542"><abbr title="authLdap_show_password_fields($return, $user)">authLdap_show_password_fields</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 9</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#569"><abbr title="authLdap_allow_password_reset($return, $userid)">authLdap_allow_password_reset</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 9</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#588"><abbr title="authLdap_sort_roles_by_capabilities($roles)">authLdap_sort_roles_by_capabilities</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 14</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#614"><abbr title="authLdap_sortByCapabilitycount($a, $b)">authLdap_sortByCapabilitycount</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 9</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#631"><abbr title="authLdap_load_options($reload = false)">authLdap_load_options</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 65</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#715"><abbr title="authLdap_get_option($optionname)">authLdap_get_option</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 9</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#729"><abbr title="authLdap_set_options($new_options = array())">authLdap_set_options</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 12</div></td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="danger" colspan="4"><a href="#760"><abbr title="authLdap_send_change_email($result, $user, $newUserData)">authLdap_send_change_email</abbr></a></td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 1</div></td>
|
|
<td class="danger small">0</td>
|
|
<td class="danger big"> <div class="progress">
|
|
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0.00" aria-valuemin="0" aria-valuemax="100" style="width: 0.00%">
|
|
<span class="sr-only">0.00% covered (danger)</span>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td class="danger small"><div align="right">0.00%</div></td>
|
|
<td class="danger small"><div align="right">0 / 6</div></td>
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
<table id="code" class="table table-borderless table-condensed">
|
|
<tbody>
|
|
<tr><td><div align="right"><a name="1"></a><a href="#1">1</a></div></td><td class="codeLine"><span class="default"><?php</span></td></tr>
|
|
<tr><td><div align="right"><a name="2"></a><a href="#2">2</a></div></td><td class="codeLine"><span class="comment">/*</span></td></tr>
|
|
<tr><td><div align="right"><a name="3"></a><a href="#3">3</a></div></td><td class="codeLine"><span class="comment">Plugin Name: AuthLDAP</span></td></tr>
|
|
<tr><td><div align="right"><a name="4"></a><a href="#4">4</a></div></td><td class="codeLine"><span class="comment">Plugin URI: https://github.com/heiglandreas/authLdap</span></td></tr>
|
|
<tr><td><div align="right"><a name="5"></a><a href="#5">5</a></div></td><td class="codeLine"><span class="comment">Description: This plugin allows you to use your existing LDAP as authentication base for WordPress</span></td></tr>
|
|
<tr><td><div align="right"><a name="6"></a><a href="#6">6</a></div></td><td class="codeLine"><span class="comment">Version: 1.4.18</span></td></tr>
|
|
<tr><td><div align="right"><a name="7"></a><a href="#7">7</a></div></td><td class="codeLine"><span class="comment">Author: Andreas Heigl <a.heigl@wdv.de></span></td></tr>
|
|
<tr><td><div align="right"><a name="8"></a><a href="#8">8</a></div></td><td class="codeLine"><span class="comment">Author URI: http://andreas.heigl.org</span></td></tr>
|
|
<tr><td><div align="right"><a name="9"></a><a href="#9">9</a></div></td><td class="codeLine"><span class="comment">*/</span></td></tr>
|
|
<tr><td><div align="right"><a name="10"></a><a href="#10">10</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="11"></a><a href="#11">11</a></div></td><td class="codeLine"><span class="keyword">require_once</span><span class="default"> </span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">'/ldap.php'</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="12"></a><a href="#12">12</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="13"></a><a href="#13">13</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">$message</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="14"></a><a href="#14">14</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="15"></a><a href="#15">15</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Debug'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="16"></a><a href="#16">16</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">error_log</span><span class="keyword">(</span><span class="default">'[AuthLDAP] '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$message</span><span class="keyword">,</span><span class="default"> </span><span class="default">0</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="17"></a><a href="#17">17</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="18"></a><a href="#18">18</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="19"></a><a href="#19">19</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="20"></a><a href="#20">20</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="21"></a><a href="#21">21</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_addmenu</span><span class="keyword">(</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="22"></a><a href="#22">22</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="23"></a><a href="#23">23</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">function_exists</span><span class="keyword">(</span><span class="default">'add_options_page'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="24"></a><a href="#24">24</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">add_options_page</span><span class="keyword">(</span><span class="default">'AuthLDAP'</span><span class="keyword">,</span><span class="default"> </span><span class="default">'AuthLDAP'</span><span class="keyword">,</span><span class="default"> </span><span class="default">'manage_options'</span><span class="keyword">,</span><span class="default"> </span><span class="default">basename</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLdap_options_panel'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="25"></a><a href="#25">25</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="26"></a><a href="#26">26</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="27"></a><a href="#27">27</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="28"></a><a href="#28">28</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">$name</span><span class="keyword">,</span><span class="default"> </span><span class="default">$default</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">''</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="29"></a><a href="#29">29</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="30"></a><a href="#30">30</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$_POST</span><span class="keyword">[</span><span class="default">$name</span><span class="keyword">]</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">?</span><span class="default"> </span><span class="default">$_POST</span><span class="keyword">[</span><span class="default">$name</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">:</span><span class="default"> </span><span class="default">$default</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="31"></a><a href="#31">31</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="32"></a><a href="#32">32</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="33"></a><a href="#33">33</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_options_panel</span><span class="keyword">(</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="34"></a><a href="#34">34</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="35"></a><a href="#35">35</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// inclusde style sheet</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="36"></a><a href="#36">36</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">wp_enqueue_style</span><span class="keyword">(</span><span class="default">'authLdap-style'</span><span class="keyword">,</span><span class="default"> </span><span class="default">plugin_dir_url</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">'authLdap.css'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="37"></a><a href="#37">37</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="38"></a><a href="#38">38</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">(</span><span class="default">$_SERVER</span><span class="keyword">[</span><span class="default">'REQUEST_METHOD'</span><span class="keyword">]</span><span class="default"> </span><span class="default">==</span><span class="default"> </span><span class="default">'POST'</span><span class="keyword">)</span><span class="default"> </span><span class="default">&&</span><span class="default"> </span><span class="default">array_key_exists</span><span class="keyword">(</span><span class="default">'ldapOptionsSave'</span><span class="keyword">,</span><span class="default"> </span><span class="default">$_POST</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="39"></a><a href="#39">39</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$new_options</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="40"></a><a href="#40">40</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Enabled'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPAuth'</span><span class="keyword">,</span><span class="default"> </span><span class="default">false</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="41"></a><a href="#41">41</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'CachePW'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPCachePW'</span><span class="keyword">,</span><span class="default"> </span><span class="default">false</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="42"></a><a href="#42">42</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'URI'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPURI'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="43"></a><a href="#43">43</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Filter'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPFilter'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="44"></a><a href="#44">44</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'NameAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPNameAttr'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="45"></a><a href="#45">45</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'SecName'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPSecName'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="46"></a><a href="#46">46</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'UidAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPUidAttr'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="47"></a><a href="#47">47</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'MailAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPMailAttr'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="48"></a><a href="#48">48</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'WebAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPWebAttr'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="49"></a><a href="#49">49</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Groups'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroups'</span><span class="keyword">,</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="50"></a><a href="#50">50</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupSeparator'</span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroupSeparator'</span><span class="keyword">,</span><span class="default"> </span><span class="default">','</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="51"></a><a href="#51">51</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Debug'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPDebug'</span><span class="keyword">,</span><span class="default"> </span><span class="default">false</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="52"></a><a href="#52">52</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroupAttr'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="53"></a><a href="#53">53</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupFilter'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroupFilter'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="54"></a><a href="#54">54</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'DefaultRole'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPDefaultRole'</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="55"></a><a href="#55">55</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupEnable'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroupEnable'</span><span class="keyword">,</span><span class="default"> </span><span class="default">false</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="56"></a><a href="#56">56</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupOverUser'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroupOverUser'</span><span class="keyword">,</span><span class="default"> </span><span class="default">false</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="57"></a><a href="#57">57</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="58"></a><a href="#58">58</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">authLdap_set_options</span><span class="keyword">(</span><span class="default">$new_options</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="59"></a><a href="#59">59</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">echo</span><span class="default"> </span><span class="default">"<div class='updated'><p>Saved Options!</p></div>"</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="60"></a><a href="#60">60</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">else</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="61"></a><a href="#61">61</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">echo</span><span class="default"> </span><span class="default">"<div class='error'><p>Could not save Options!</p></div>"</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="62"></a><a href="#62">62</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="63"></a><a href="#63">63</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="64"></a><a href="#64">64</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="65"></a><a href="#65">65</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// Do some initialization for the admin-view</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="66"></a><a href="#66">66</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAP</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Enabled'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="67"></a><a href="#67">67</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPCachePW</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'CachePW'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="68"></a><a href="#68">68</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPURI</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'URI'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="69"></a><a href="#69">69</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPFilter</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Filter'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="70"></a><a href="#70">70</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPNameAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'NameAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="71"></a><a href="#71">71</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPSecName</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'SecName'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="72"></a><a href="#72">72</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPMailAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'MailAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="73"></a><a href="#73">73</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPUidAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'UidAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="74"></a><a href="#74">74</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPWebAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'WebAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="75"></a><a href="#75">75</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroups</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Groups'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="76"></a><a href="#76">76</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupSeparator</span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupSeparator'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="77"></a><a href="#77">77</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPDebug</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Debug'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="78"></a><a href="#78">78</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="79"></a><a href="#79">79</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupFilter</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupFilter'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="80"></a><a href="#80">80</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPDefaultRole</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'DefaultRole'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="81"></a><a href="#81">81</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupEnable</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupEnable'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="82"></a><a href="#82">82</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupOverUser</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupOverUser'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="83"></a><a href="#83">83</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="84"></a><a href="#84">84</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$tChecked</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">(</span><span class="default">$authLDAP</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">?</span><span class="default"> </span><span class="default">' checked="checked"'</span><span class="default"> </span><span class="keyword">:</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="85"></a><a href="#85">85</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$tDebugChecked</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">(</span><span class="default">$authLDAPDebug</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">?</span><span class="default"> </span><span class="default">' checked="checked"'</span><span class="default"> </span><span class="keyword">:</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="86"></a><a href="#86">86</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$tPWChecked</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">(</span><span class="default">$authLDAPCachePW</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">?</span><span class="default"> </span><span class="default">' checked="checked"'</span><span class="default"> </span><span class="keyword">:</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="87"></a><a href="#87">87</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$tGroupChecked</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">(</span><span class="default">$authLDAPGroupEnable</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">?</span><span class="default"> </span><span class="default">' checked="checked"'</span><span class="default"> </span><span class="keyword">:</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="88"></a><a href="#88">88</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$tGroupOverUserChecked</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">(</span><span class="default">$authLDAPGroupOverUser</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">?</span><span class="default"> </span><span class="default">' checked="checked"'</span><span class="default"> </span><span class="keyword">:</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="89"></a><a href="#89">89</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="90"></a><a href="#90">90</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$roles</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">new</span><span class="default"> </span><span class="default">WP_Roles</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="91"></a><a href="#91">91</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="92"></a><a href="#92">92</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$action</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$_SERVER</span><span class="keyword">[</span><span class="default">'REQUEST_URI'</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="93"></a><a href="#93">93</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">extension_loaded</span><span class="keyword">(</span><span class="default">'ldap'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="94"></a><a href="#94">94</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">echo</span><span class="default"> </span><span class="default">'<div class="warning">The LDAP-Extension is not available on your '</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="95"></a><a href="#95">95</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">'WebServer. Therefore Everything you can alter here does not '</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="96"></a><a href="#96">96</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">'make any sense!</div>'</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="97"></a><a href="#97">97</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="98"></a><a href="#98">98</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="99"></a><a href="#99">99</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">include</span><span class="default"> </span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">'/view/admin.phtml'</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="100"></a><a href="#100">100</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="101"></a><a href="#101">101</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="102"></a><a href="#102">102</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="103"></a><a href="#103">103</a></div></td><td class="codeLine"><span class="comment"> * get a LDAP server object</span></td></tr>
|
|
<tr><td><div align="right"><a name="104"></a><a href="#104">104</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="105"></a><a href="#105">105</a></div></td><td class="codeLine"><span class="comment"> * throws exception if there is a problem connecting</span></td></tr>
|
|
<tr><td><div align="right"><a name="106"></a><a href="#106">106</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="107"></a><a href="#107">107</a></div></td><td class="codeLine"><span class="comment"> * @return object LDAP server object</span></td></tr>
|
|
<tr><td><div align="right"><a name="108"></a><a href="#108">108</a></div></td><td class="codeLine"><span class="comment"> * @conf boolean authLDAPDebug true, if debugging should be turned on</span></td></tr>
|
|
<tr><td><div align="right"><a name="109"></a><a href="#109">109</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPURI LDAP server URI</span></td></tr>
|
|
<tr><td><div align="right"><a name="110"></a><a href="#110">110</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="111"></a><a href="#111">111</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="112"></a><a href="#112">112</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="113"></a><a href="#113">113</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">static</span><span class="default"> </span><span class="default">$_server</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">null</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="114"></a><a href="#114">114</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">is_null</span><span class="keyword">(</span><span class="default">$_server</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="115"></a><a href="#115">115</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPDebug</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Debug'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="116"></a><a href="#116">116</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPURI</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'URI'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="117"></a><a href="#117">117</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="118"></a><a href="#118">118</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">//$authLDAPURI = 'ldap:/foo:bar@server/trallala';</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="119"></a><a href="#119">119</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'connect to LDAP server'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="120"></a><a href="#120">120</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$_server</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">new</span><span class="default"> </span><span class="default">LDAP</span><span class="keyword">(</span><span class="default">$authLDAPURI</span><span class="keyword">,</span><span class="default"> </span><span class="default">$authLDAPDebug</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="121"></a><a href="#121">121</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="122"></a><a href="#122">122</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$_server</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="123"></a><a href="#123">123</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="124"></a><a href="#124">124</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="125"></a><a href="#125">125</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="126"></a><a href="#126">126</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="127"></a><a href="#127">127</a></div></td><td class="codeLine"><span class="comment"> * This method authenticates a user using either the LDAP or, if LDAP is not</span></td></tr>
|
|
<tr><td><div align="right"><a name="128"></a><a href="#128">128</a></div></td><td class="codeLine"><span class="comment"> * available, the local database</span></td></tr>
|
|
<tr><td><div align="right"><a name="129"></a><a href="#129">129</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="130"></a><a href="#130">130</a></div></td><td class="codeLine"><span class="comment"> * For this we store the hashed passwords in the WP_Database to ensure working</span></td></tr>
|
|
<tr><td><div align="right"><a name="131"></a><a href="#131">131</a></div></td><td class="codeLine"><span class="comment"> * conditions even without an LDAP-Connection</span></td></tr>
|
|
<tr><td><div align="right"><a name="132"></a><a href="#132">132</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="133"></a><a href="#133">133</a></div></td><td class="codeLine"><span class="comment"> * @param null|WP_User|WP_Error</span></td></tr>
|
|
<tr><td><div align="right"><a name="134"></a><a href="#134">134</a></div></td><td class="codeLine"><span class="comment"> * @param string $username</span></td></tr>
|
|
<tr><td><div align="right"><a name="135"></a><a href="#135">135</a></div></td><td class="codeLine"><span class="comment"> * @param string $password</span></td></tr>
|
|
<tr><td><div align="right"><a name="136"></a><a href="#136">136</a></div></td><td class="codeLine"><span class="comment"> * @param boolean $already_md5</span></td></tr>
|
|
<tr><td><div align="right"><a name="137"></a><a href="#137">137</a></div></td><td class="codeLine"><span class="comment"> * @return boolean true, if login was successfull or false, if it wasn't</span></td></tr>
|
|
<tr><td><div align="right"><a name="138"></a><a href="#138">138</a></div></td><td class="codeLine"><span class="comment"> * @conf boolean authLDAP true, if authLDAP should be used, false if not. Defaults to false</span></td></tr>
|
|
<tr><td><div align="right"><a name="139"></a><a href="#139">139</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPFilter LDAP filter to use to find correct user, defaults to '(uid=%s)'</span></td></tr>
|
|
<tr><td><div align="right"><a name="140"></a><a href="#140">140</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPNameAttr LDAP attribute containing user (display) name, defaults to 'name'</span></td></tr>
|
|
<tr><td><div align="right"><a name="141"></a><a href="#141">141</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPSecName LDAP attribute containing second name, defaults to ''</span></td></tr>
|
|
<tr><td><div align="right"><a name="142"></a><a href="#142">142</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPMailAttr LDAP attribute containing user e-mail, defaults to 'mail'</span></td></tr>
|
|
<tr><td><div align="right"><a name="143"></a><a href="#143">143</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPUidAttr LDAP attribute containing user id (the username we log on with), defaults to 'uid'</span></td></tr>
|
|
<tr><td><div align="right"><a name="144"></a><a href="#144">144</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPWebAttr LDAP attribute containing user website, defaults to ''</span></td></tr>
|
|
<tr><td><div align="right"><a name="145"></a><a href="#145">145</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPDefaultRole default role for authenticated user, defaults to ''</span></td></tr>
|
|
<tr><td><div align="right"><a name="146"></a><a href="#146">146</a></div></td><td class="codeLine"><span class="comment"> * @conf boolean authLDAPGroupEnable true, if we try to map LDAP groups to Wordpress roles</span></td></tr>
|
|
<tr><td><div align="right"><a name="147"></a><a href="#147">147</a></div></td><td class="codeLine"><span class="comment"> * @conf boolean authLDAPGroupOverUser true, if LDAP Groups have precedence over existing user roles</span></td></tr>
|
|
<tr><td><div align="right"><a name="148"></a><a href="#148">148</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="149"></a><a href="#149">149</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_login</span><span class="keyword">(</span><span class="default">$user</span><span class="keyword">,</span><span class="default"> </span><span class="default">$username</span><span class="keyword">,</span><span class="default"> </span><span class="default">$password</span><span class="keyword">,</span><span class="default"> </span><span class="default">$already_md5</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">false</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="150"></a><a href="#150">150</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="151"></a><a href="#151">151</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// don't do anything when authLDAP is disabled</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="152"></a><a href="#152">152</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Enabled'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="153"></a><a href="#153">153</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP disabled in AuthLDAP plugin options (use the first option in the AuthLDAP options to enable it)'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="154"></a><a href="#154">154</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$user</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="155"></a><a href="#155">155</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="156"></a><a href="#156">156</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="157"></a><a href="#157">157</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// If the user has already been authenticated (only in that case we get a</span></td></tr>
|
|
<tr><td><div align="right"><a name="158"></a><a href="#158">158</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// WP_User-Object as $user) we skip LDAP-authentication and simply return</span></td></tr>
|
|
<tr><td><div align="right"><a name="159"></a><a href="#159">159</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// the existing user-object</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="160"></a><a href="#160">160</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">$user</span><span class="default"> </span><span class="keyword">instanceof</span><span class="default"> </span><span class="default">WP_User</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="161"></a><a href="#161">161</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">sprintf</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="162"></a><a href="#162">162</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'User %s has already been authenticated - skipping LDAP-Authentication'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="163"></a><a href="#163">163</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user</span><span class="default">-></span><span class="default">get</span><span class="keyword">(</span><span class="default">'nickname'</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="164"></a><a href="#164">164</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$user</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="165"></a><a href="#165">165</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="166"></a><a href="#166">166</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="167"></a><a href="#167">167</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="string">"</span><span class="string">User '</span><span class="string">$username</span><span class="string">' logging in</span><span class="string">"</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="168"></a><a href="#168">168</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="169"></a><a href="#169">169</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">$username</span><span class="default"> </span><span class="default">==</span><span class="default"> </span><span class="default">'admin'</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="170"></a><a href="#170">170</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Doing nothing for possible local user admin'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="171"></a><a href="#171">171</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$user</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="172"></a><a href="#172">172</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="173"></a><a href="#173">173</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="174"></a><a href="#174">174</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">global</span><span class="default"> </span><span class="default">$wpdb</span><span class="keyword">,</span><span class="default"> </span><span class="default">$error</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="175"></a><a href="#175">175</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">try</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="176"></a><a href="#176">176</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAP</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Enabled'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="177"></a><a href="#177">177</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPFilter</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Filter'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="178"></a><a href="#178">178</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPNameAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'NameAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="179"></a><a href="#179">179</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPSecName</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'SecName'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="180"></a><a href="#180">180</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPMailAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'MailAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="181"></a><a href="#181">181</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPUidAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'UidAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="182"></a><a href="#182">182</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPWebAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'WebAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="183"></a><a href="#183">183</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPDefaultRole</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'DefaultRole'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="184"></a><a href="#184">184</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupEnable</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupEnable'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="185"></a><a href="#185">185</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupOverUser</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupOverUser'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="186"></a><a href="#186">186</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="187"></a><a href="#187">187</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$username</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="188"></a><a href="#188">188</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Username not supplied: return false'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="189"></a><a href="#189">189</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="190"></a><a href="#190">190</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="191"></a><a href="#191">191</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="192"></a><a href="#192">192</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$password</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="193"></a><a href="#193">193</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Password not supplied: return false'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="194"></a><a href="#194">194</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$error</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">__</span><span class="keyword">(</span><span class="default">'<strong>Error</strong>: The password field is empty.'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="195"></a><a href="#195">195</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="196"></a><a href="#196">196</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="197"></a><a href="#197">197</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// First check for valid values and set appropriate defaults</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="198"></a><a href="#198">198</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$authLDAPFilter</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="199"></a><a href="#199">199</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPFilter</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">'(uid=%s)'</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="200"></a><a href="#200">200</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="201"></a><a href="#201">201</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$authLDAPNameAttr</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="202"></a><a href="#202">202</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPNameAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">'name'</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="203"></a><a href="#203">203</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="204"></a><a href="#204">204</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$authLDAPMailAttr</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="205"></a><a href="#205">205</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPMailAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">'mail'</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="206"></a><a href="#206">206</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="207"></a><a href="#207">207</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$authLDAPUidAttr</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="208"></a><a href="#208">208</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPUidAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">'uid'</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="209"></a><a href="#209">209</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="210"></a><a href="#210">210</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="211"></a><a href="#211">211</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// If already_md5 is TRUE, then we're getting the user/password from the cookie. As we don't want to store LDAP passwords in any</span></td></tr>
|
|
<tr><td><div align="right"><a name="212"></a><a href="#212">212</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// form, we've already replaced the password with the hashed username and LDAP_COOKIE_MARKER</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="213"></a><a href="#213">213</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">$already_md5</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="214"></a><a href="#214">214</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">$password</span><span class="default"> </span><span class="default">==</span><span class="default"> </span><span class="default">md5</span><span class="keyword">(</span><span class="default">$username</span><span class="keyword">)</span><span class="keyword">.</span><span class="default">md5</span><span class="keyword">(</span><span class="default">$ldapCookieMarker</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="215"></a><a href="#215">215</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'cookie authentication'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="216"></a><a href="#216">216</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">true</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="217"></a><a href="#217">217</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="218"></a><a href="#218">218</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="219"></a><a href="#219">219</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="220"></a><a href="#220">220</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// No cookie, so have to authenticate them via LDAP</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="221"></a><a href="#221">221</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$result</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="222"></a><a href="#222">222</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">try</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="223"></a><a href="#223">223</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'about to do LDAP authentication'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="224"></a><a href="#224">224</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$result</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">-></span><span class="default">Authenticate</span><span class="keyword">(</span><span class="default">$username</span><span class="keyword">,</span><span class="default"> </span><span class="default">$password</span><span class="keyword">,</span><span class="default"> </span><span class="default">$authLDAPFilter</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="225"></a><a href="#225">225</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">catch</span><span class="default"> </span><span class="keyword">(</span><span class="default">Exception</span><span class="default"> </span><span class="default">$e</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="226"></a><a href="#226">226</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP authentication failed with exception: '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$e</span><span class="default">-></span><span class="default">getMessage</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="227"></a><a href="#227">227</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="228"></a><a href="#228">228</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="229"></a><a href="#229">229</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="230"></a><a href="#230">230</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// Rebind with the default credentials after the user has been loged in</span></td></tr>
|
|
<tr><td><div align="right"><a name="231"></a><a href="#231">231</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// Otherwise the credentials of the user trying to login will be used</span></td></tr>
|
|
<tr><td><div align="right"><a name="232"></a><a href="#232">232</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// This fixes #55</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="233"></a><a href="#233">233</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">-></span><span class="default">bind</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="234"></a><a href="#234">234</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="235"></a><a href="#235">235</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">true</span><span class="default"> </span><span class="default">!==</span><span class="default"> </span><span class="default">$result</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="236"></a><a href="#236">236</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP authentication failed'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="237"></a><a href="#237">237</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// TODO what to return? WP_User object, true, false, even an WP_Error object... all seem to fall back to normal wp user authentication</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="238"></a><a href="#238">238</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="239"></a><a href="#239">239</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="240"></a><a href="#240">240</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="241"></a><a href="#241">241</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP authentication successfull'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="242"></a><a href="#242">242</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$attributes</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">array_values</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="243"></a><a href="#243">243</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">array_filter</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="244"></a><a href="#244">244</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="245"></a><a href="#245">245</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPNameAttr</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="246"></a><a href="#246">246</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPSecName</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="247"></a><a href="#247">247</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPMailAttr</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="248"></a><a href="#248">248</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPWebAttr</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="249"></a><a href="#249">249</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPUidAttr</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="250"></a><a href="#250">250</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="251"></a><a href="#251">251</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="252"></a><a href="#252">252</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="253"></a><a href="#253">253</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="254"></a><a href="#254">254</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">try</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="255"></a><a href="#255">255</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$attribs</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">-></span><span class="default">search</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="256"></a><a href="#256">256</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">sprintf</span><span class="keyword">(</span><span class="default">$authLDAPFilter</span><span class="keyword">,</span><span class="default"> </span><span class="default">$username</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="257"></a><a href="#257">257</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$attributes</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="258"></a><a href="#258">258</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="259"></a><a href="#259">259</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// First get all the relevant group informations so we can see if</span></td></tr>
|
|
<tr><td><div align="right"><a name="260"></a><a href="#260">260</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// whether have been changes in group association of the user</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="261"></a><a href="#261">261</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">'dn'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="262"></a><a href="#262">262</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'could not get user attributes from LDAP'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="263"></a><a href="#263">263</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">throw</span><span class="default"> </span><span class="keyword">new</span><span class="default"> </span><span class="default">UnexpectedValueException</span><span class="keyword">(</span><span class="default">'dn has not been returned'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="264"></a><a href="#264">264</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="265"></a><a href="#265">265</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPUidAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="266"></a><a href="#266">266</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'could not get user attributes from LDAP'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="267"></a><a href="#267">267</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">throw</span><span class="default"> </span><span class="keyword">new</span><span class="default"> </span><span class="default">UnexpectedValueException</span><span class="keyword">(</span><span class="default">'The user-ID attribute has not been returned'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="268"></a><a href="#268">268</a></div></td><td class="codeLine"><span class="default"> </span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="269"></a><a href="#269">269</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="270"></a><a href="#270">270</a></div></td><td class="codeLine"><span class="default"> </span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="271"></a><a href="#271">271</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$dn</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">'dn'</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="272"></a><a href="#272">272</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$realuid</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPUidAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="273"></a><a href="#273">273</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">catch</span><span class="default"> </span><span class="keyword">(</span><span class="default">Exception</span><span class="default"> </span><span class="default">$e</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="274"></a><a href="#274">274</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Exception getting LDAP user: '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$e</span><span class="default">-></span><span class="default">getMessage</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="275"></a><a href="#275">275</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="276"></a><a href="#276">276</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="277"></a><a href="#277">277</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="278"></a><a href="#278">278</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$uid</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_uid</span><span class="keyword">(</span><span class="default">$realuid</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="279"></a><a href="#279">279</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$role</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="280"></a><a href="#280">280</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="281"></a><a href="#281">281</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// we only need this if either LDAP groups are disabled or</span></td></tr>
|
|
<tr><td><div align="right"><a name="282"></a><a href="#282">282</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// if the WordPress role of the user overrides LDAP groups</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="283"></a><a href="#283">283</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default">$authLDAPGroupEnable</span><span class="default"> </span><span class="default">||</span><span class="default"> </span><span class="keyword">!</span><span class="default">$authLDAPGroupOverUser</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="284"></a><a href="#284">284</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$role</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_user_role</span><span class="keyword">(</span><span class="default">$uid</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="285"></a><a href="#285">285</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="286"></a><a href="#286">286</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="287"></a><a href="#287">287</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// do LDAP group mapping if needed</span></td></tr>
|
|
<tr><td><div align="right"><a name="288"></a><a href="#288">288</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// (if LDAP groups override worpress user role, $role is still empty)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="289"></a><a href="#289">289</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">empty</span><span class="keyword">(</span><span class="default">$role</span><span class="keyword">)</span><span class="default"> </span><span class="default">&&</span><span class="default"> </span><span class="default">$authLDAPGroupEnable</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="290"></a><a href="#290">290</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$role</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_groupmap</span><span class="keyword">(</span><span class="default">$realuid</span><span class="keyword">,</span><span class="default"> </span><span class="default">$dn</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="291"></a><a href="#291">291</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'role from group mapping: '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$role</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="292"></a><a href="#292">292</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="293"></a><a href="#293">293</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="294"></a><a href="#294">294</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// if we don't have a role yet, use default role</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="295"></a><a href="#295">295</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">empty</span><span class="keyword">(</span><span class="default">$role</span><span class="keyword">)</span><span class="default"> </span><span class="default">&&</span><span class="default"> </span><span class="keyword">!</span><span class="keyword">empty</span><span class="keyword">(</span><span class="default">$authLDAPDefaultRole</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="296"></a><a href="#296">296</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'no role yet, set default role'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="297"></a><a href="#297">297</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$role</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$authLDAPDefaultRole</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="298"></a><a href="#298">298</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="299"></a><a href="#299">299</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="300"></a><a href="#300">300</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">empty</span><span class="keyword">(</span><span class="default">$role</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="301"></a><a href="#301">301</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// Sorry, but you are not in any group that is allowed access</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="302"></a><a href="#302">302</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">trigger_error</span><span class="keyword">(</span><span class="default">'no group found'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="303"></a><a href="#303">303</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'user is not in any group that is allowed access'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="304"></a><a href="#304">304</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="305"></a><a href="#305">305</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">else</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="306"></a><a href="#306">306</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$roles</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">new</span><span class="default"> </span><span class="default">WP_Roles</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="307"></a><a href="#307">307</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// not sure if this is needed, but it can't hurt</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="308"></a><a href="#308">308</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default">$roles</span><span class="default">-></span><span class="default">is_role</span><span class="keyword">(</span><span class="default">$role</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="309"></a><a href="#309">309</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">trigger_error</span><span class="keyword">(</span><span class="default">'no group found'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="310"></a><a href="#310">310</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'role is invalid'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="311"></a><a href="#311">311</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="312"></a><a href="#312">312</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="313"></a><a href="#313">313</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="314"></a><a href="#314">314</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="315"></a><a href="#315">315</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// from here on, the user has access!</span></td></tr>
|
|
<tr><td><div align="right"><a name="316"></a><a href="#316">316</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// now, lets update some user details</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="317"></a><a href="#317">317</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="318"></a><a href="#318">318</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_login'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$realuid</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="319"></a><a href="#319">319</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'role'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$role</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="320"></a><a href="#320">320</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_email'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="321"></a><a href="#321">321</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="322"></a><a href="#322">322</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// first name</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="323"></a><a href="#323">323</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPNameAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="324"></a><a href="#324">324</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'first_name'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPNameAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="325"></a><a href="#325">325</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="326"></a><a href="#326">326</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="327"></a><a href="#327">327</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// last name</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="328"></a><a href="#328">328</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPSecName</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="329"></a><a href="#329">329</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'last_name'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPSecName</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="330"></a><a href="#330">330</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="331"></a><a href="#331">331</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="332"></a><a href="#332">332</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// mail address</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="333"></a><a href="#333">333</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPMailAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="334"></a><a href="#334">334</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_email'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPMailAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="335"></a><a href="#335">335</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="336"></a><a href="#336">336</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="337"></a><a href="#337">337</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// website</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="338"></a><a href="#338">338</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPWebAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="339"></a><a href="#339">339</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_url'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$attribs</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPWebAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="340"></a><a href="#340">340</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="341"></a><a href="#341">341</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="342"></a><a href="#342">342</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// display name, nickname, nicename</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="343"></a><a href="#343">343</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">array_key_exists</span><span class="keyword">(</span><span class="default">'first_name'</span><span class="keyword">,</span><span class="default"> </span><span class="default">$user_info</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="344"></a><a href="#344">344</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'display_name'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'first_name'</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="345"></a><a href="#345">345</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'nickname'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'first_name'</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="346"></a><a href="#346">346</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_nicename'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">sanitize_title_with_dashes</span><span class="keyword">(</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'first_name'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="347"></a><a href="#347">347</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">array_key_exists</span><span class="keyword">(</span><span class="default">'last_name'</span><span class="keyword">,</span><span class="default"> </span><span class="default">$user_info</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="348"></a><a href="#348">348</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'display_name'</span><span class="keyword">]</span><span class="default"> </span><span class="default">.=</span><span class="default"> </span><span class="default">' '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'last_name'</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="349"></a><a href="#349">349</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'nickname'</span><span class="keyword">]</span><span class="default"> </span><span class="default">.=</span><span class="default"> </span><span class="default">' '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'last_name'</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="350"></a><a href="#350">350</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_nicename'</span><span class="keyword">]</span><span class="default"> </span><span class="default">.=</span><span class="default"> </span><span class="default">'_'</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">sanitize_title_with_dashes</span><span class="keyword">(</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'last_name'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="351"></a><a href="#351">351</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="352"></a><a href="#352">352</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="353"></a><a href="#353">353</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="354"></a><a href="#354">354</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// optionally store the password into the wordpress database</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="355"></a><a href="#355">355</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'CachePW'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="356"></a><a href="#356">356</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// Password will be hashed inside wp_update_user or wp_insert_user</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="357"></a><a href="#357">357</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_pass'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$password</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="358"></a><a href="#358">358</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">else</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="359"></a><a href="#359">359</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// clear the password</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="360"></a><a href="#360">360</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_pass'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="361"></a><a href="#361">361</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="362"></a><a href="#362">362</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="363"></a><a href="#363">363</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// add uid if user exists</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="364"></a><a href="#364">364</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">$uid</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="365"></a><a href="#365">365</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// found user in the database</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="366"></a><a href="#366">366</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'The LDAP user has an entry in the WP-Database'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="367"></a><a href="#367">367</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'ID'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$uid</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="368"></a><a href="#368">368</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">unset</span><span class="default"> </span><span class="keyword">(</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'display_name'</span><span class="keyword">]</span><span class="keyword">,</span><span class="default"> </span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'nickname'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="369"></a><a href="#369">369</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$userid</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">wp_update_user</span><span class="keyword">(</span><span class="default">$user_info</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="370"></a><a href="#370">370</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">else</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="371"></a><a href="#371">371</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// new wordpress account will be created</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="372"></a><a href="#372">372</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'The LDAP user does not have an entry in the WP-Database, a new WP account will be created'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="373"></a><a href="#373">373</a></div></td><td class="codeLine"><span class="default"> </span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="374"></a><a href="#374">374</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$userid</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">wp_insert_user</span><span class="keyword">(</span><span class="default">$user_info</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="375"></a><a href="#375">375</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="376"></a><a href="#376">376</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="377"></a><a href="#377">377</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// if the user exists, wp_insert_user will update the existing user record</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="378"></a><a href="#378">378</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">is_wp_error</span><span class="keyword">(</span><span class="default">$userid</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="379"></a><a href="#379">379</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Error creating user : '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$userid</span><span class="default">-></span><span class="default">get_error_message</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="380"></a><a href="#380">380</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">trigger_error</span><span class="keyword">(</span><span class="default">'Error creating user: '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$userid</span><span class="default">-></span><span class="default">get_error_message</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="381"></a><a href="#381">381</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$userid</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="382"></a><a href="#382">382</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="383"></a><a href="#383">383</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="384"></a><a href="#384">384</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'user id = '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$userid</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="385"></a><a href="#385">385</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="386"></a><a href="#386">386</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// flag the user as an ldap user so we can hide the password fields in the user profile</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="387"></a><a href="#387">387</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">update_user_meta</span><span class="keyword">(</span><span class="default">$userid</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLDAP'</span><span class="keyword">,</span><span class="default"> </span><span class="default">true</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="388"></a><a href="#388">388</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="389"></a><a href="#389">389</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// return a user object upon positive authorization</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="390"></a><a href="#390">390</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="keyword">new</span><span class="default"> </span><span class="default">WP_User</span><span class="keyword">(</span><span class="default">$userid</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="391"></a><a href="#391">391</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">catch</span><span class="default"> </span><span class="keyword">(</span><span class="default">Exception</span><span class="default"> </span><span class="default">$e</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="392"></a><a href="#392">392</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">$e</span><span class="default">-></span><span class="default">getMessage</span><span class="keyword">(</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">'. Exception thrown in line '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$e</span><span class="default">-></span><span class="default">getLine</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="393"></a><a href="#393">393</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">trigger_error</span><span class="keyword">(</span><span class="default">$e</span><span class="default">-></span><span class="default">getMessage</span><span class="keyword">(</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">'. Exception thrown in line '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$e</span><span class="default">-></span><span class="default">getLine</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="394"></a><a href="#394">394</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="395"></a><a href="#395">395</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="396"></a><a href="#396">396</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="397"></a><a href="#397">397</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="398"></a><a href="#398">398</a></div></td><td class="codeLine"><span class="comment"> * Get user's user id</span></td></tr>
|
|
<tr><td><div align="right"><a name="399"></a><a href="#399">399</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="400"></a><a href="#400">400</a></div></td><td class="codeLine"><span class="comment"> * Returns null if username not found</span></td></tr>
|
|
<tr><td><div align="right"><a name="401"></a><a href="#401">401</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="402"></a><a href="#402">402</a></div></td><td class="codeLine"><span class="comment"> * @param string $username username</span></td></tr>
|
|
<tr><td><div align="right"><a name="403"></a><a href="#403">403</a></div></td><td class="codeLine"><span class="comment"> * @param string user id, null if not found</span></td></tr>
|
|
<tr><td><div align="right"><a name="404"></a><a href="#404">404</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="405"></a><a href="#405">405</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_get_uid</span><span class="keyword">(</span><span class="default">$username</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="406"></a><a href="#406">406</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="407"></a><a href="#407">407</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">global</span><span class="default"> </span><span class="default">$wpdb</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="408"></a><a href="#408">408</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="409"></a><a href="#409">409</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// find out whether the user is already present in the database</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="410"></a><a href="#410">410</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$uid</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$wpdb</span><span class="default">-></span><span class="default">get_var</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="411"></a><a href="#411">411</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$wpdb</span><span class="default">-></span><span class="default">prepare</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="412"></a><a href="#412">412</a></div></td><td class="codeLine"><span class="default"> </span><span class="string">"</span><span class="string">SELECT ID FROM </span><span class="string">{</span><span class="string">$wpdb</span><span class="string">-></span><span class="string">users</span><span class="keyword">}</span><span class="string"> WHERE user_login = %s</span><span class="string">"</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="413"></a><a href="#413">413</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$username</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="414"></a><a href="#414">414</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="415"></a><a href="#415">415</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="416"></a><a href="#416">416</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">$uid</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="417"></a><a href="#417">417</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="string">"</span><span class="string">Existing user, uid = </span><span class="string">{</span><span class="string">$uid</span><span class="keyword">}</span><span class="string">"</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="418"></a><a href="#418">418</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$uid</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="419"></a><a href="#419">419</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">else</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="420"></a><a href="#420">420</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">null</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="421"></a><a href="#421">421</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="422"></a><a href="#422">422</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="423"></a><a href="#423">423</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="424"></a><a href="#424">424</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="425"></a><a href="#425">425</a></div></td><td class="codeLine"><span class="comment"> * Get the user's current role</span></td></tr>
|
|
<tr><td><div align="right"><a name="426"></a><a href="#426">426</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="427"></a><a href="#427">427</a></div></td><td class="codeLine"><span class="comment"> * Returns empty string if not found.</span></td></tr>
|
|
<tr><td><div align="right"><a name="428"></a><a href="#428">428</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="429"></a><a href="#429">429</a></div></td><td class="codeLine"><span class="comment"> * @param int $uid wordpress user id</span></td></tr>
|
|
<tr><td><div align="right"><a name="430"></a><a href="#430">430</a></div></td><td class="codeLine"><span class="comment"> * @return string role, empty if none found</span></td></tr>
|
|
<tr><td><div align="right"><a name="431"></a><a href="#431">431</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="432"></a><a href="#432">432</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_user_role</span><span class="keyword">(</span><span class="default">$uid</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="433"></a><a href="#433">433</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="434"></a><a href="#434">434</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">global</span><span class="default"> </span><span class="default">$wpdb</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="435"></a><a href="#435">435</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="436"></a><a href="#436">436</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default">$uid</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="437"></a><a href="#437">437</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="438"></a><a href="#438">438</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="439"></a><a href="#439">439</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="440"></a><a href="#440">440</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$meta_value</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$wpdb</span><span class="default">-></span><span class="default">get_var</span><span class="keyword">(</span><span class="string">"</span><span class="string">SELECT meta_value FROM </span><span class="string">{</span><span class="string">$wpdb</span><span class="string">-></span><span class="string">usermeta</span><span class="keyword">}</span><span class="string"> WHERE meta_key = '</span><span class="string">{</span><span class="string">$wpdb</span><span class="string">-></span><span class="string">prefix</span><span class="keyword">}</span><span class="string">capabilities' AND user_id = </span><span class="string">{</span><span class="string">$uid</span><span class="keyword">}</span><span class="string">"</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="441"></a><a href="#441">441</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="442"></a><a href="#442">442</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default">$meta_value</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="443"></a><a href="#443">443</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="444"></a><a href="#444">444</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="445"></a><a href="#445">445</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="446"></a><a href="#446">446</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$capabilities</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">unserialize</span><span class="keyword">(</span><span class="default">$meta_value</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="447"></a><a href="#447">447</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$roles</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">is_array</span><span class="keyword">(</span><span class="default">$capabilities</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">?</span><span class="default"> </span><span class="default">array_keys</span><span class="keyword">(</span><span class="default">$capabilities</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">:</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="default">''</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="448"></a><a href="#448">448</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$role</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$roles</span><span class="keyword">[</span><span class="default">0</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="449"></a><a href="#449">449</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="450"></a><a href="#450">450</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="string">"</span><span class="string">Existing user's role: </span><span class="string">{</span><span class="string">$role</span><span class="keyword">}</span><span class="string">"</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="451"></a><a href="#451">451</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$role</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="452"></a><a href="#452">452</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="453"></a><a href="#453">453</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="454"></a><a href="#454">454</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="455"></a><a href="#455">455</a></div></td><td class="codeLine"><span class="comment"> * Get LDAP groups for user and map to role</span></td></tr>
|
|
<tr><td><div align="right"><a name="456"></a><a href="#456">456</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="457"></a><a href="#457">457</a></div></td><td class="codeLine"><span class="comment"> * @param string $username</span></td></tr>
|
|
<tr><td><div align="right"><a name="458"></a><a href="#458">458</a></div></td><td class="codeLine"><span class="comment"> * @param string $dn</span></td></tr>
|
|
<tr><td><div align="right"><a name="459"></a><a href="#459">459</a></div></td><td class="codeLine"><span class="comment"> * @return string role, empty string if no mapping found, first found role otherwise</span></td></tr>
|
|
<tr><td><div align="right"><a name="460"></a><a href="#460">460</a></div></td><td class="codeLine"><span class="comment"> * @conf array authLDAPGroups, associative array, role => ldap_group</span></td></tr>
|
|
<tr><td><div align="right"><a name="461"></a><a href="#461">461</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPGroupAttr, ldap attribute that holds name of group</span></td></tr>
|
|
<tr><td><div align="right"><a name="462"></a><a href="#462">462</a></div></td><td class="codeLine"><span class="comment"> * @conf string authLDAPGroupFilter, LDAP filter to find groups. can contain %s and %dn% placeholders</span></td></tr>
|
|
<tr><td><div align="right"><a name="463"></a><a href="#463">463</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="464"></a><a href="#464">464</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_groupmap</span><span class="keyword">(</span><span class="default">$username</span><span class="keyword">,</span><span class="default"> </span><span class="default">$dn</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="465"></a><a href="#465">465</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="466"></a><a href="#466">466</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroups</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_sort_roles_by_capabilities</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="467"></a><a href="#467">467</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'Groups'</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="468"></a><a href="#468">468</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="469"></a><a href="#469">469</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupAttr'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="470"></a><a href="#470">470</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupFilter</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupFilter'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="471"></a><a href="#471">471</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupSeparator</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">'GroupSeparator'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="472"></a><a href="#472">472</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$authLDAPGroupAttr</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="473"></a><a href="#473">473</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupAttr</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">'gidNumber'</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="474"></a><a href="#474">474</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="475"></a><a href="#475">475</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$authLDAPGroupFilter</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="476"></a><a href="#476">476</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupFilter</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">'(&(objectClass=posixGroup)(memberUid=%s))'</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="477"></a><a href="#477">477</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="478"></a><a href="#478">478</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$authLDAPGroupSeparator</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="479"></a><a href="#479">479</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupSeparator</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">','</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="480"></a><a href="#480">480</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="481"></a><a href="#481">481</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="482"></a><a href="#482">482</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default">is_array</span><span class="keyword">(</span><span class="default">$authLDAPGroups</span><span class="keyword">)</span><span class="default"> </span><span class="default">||</span><span class="default"> </span><span class="default">count</span><span class="keyword">(</span><span class="default">array_filter</span><span class="keyword">(</span><span class="default">array_values</span><span class="keyword">(</span><span class="default">$authLDAPGroups</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="default">==</span><span class="default"> </span><span class="default">0</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="483"></a><a href="#483">483</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'No group names defined'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="484"></a><a href="#484">484</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="485"></a><a href="#485">485</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="486"></a><a href="#486">486</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="487"></a><a href="#487">487</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">try</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="488"></a><a href="#488">488</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// To allow searches based on the DN instead of the uid, we replace the</span></td></tr>
|
|
<tr><td><div align="right"><a name="489"></a><a href="#489">489</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// string %dn% with the users DN.</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="490"></a><a href="#490">490</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$authLDAPGroupFilter</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">str_replace</span><span class="keyword">(</span><span class="default">'%dn%'</span><span class="keyword">,</span><span class="default"> </span><span class="default">$dn</span><span class="keyword">,</span><span class="default"> </span><span class="default">$authLDAPGroupFilter</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="491"></a><a href="#491">491</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Group Filter: '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">json_encode</span><span class="keyword">(</span><span class="default">$authLDAPGroupFilter</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="492"></a><a href="#492">492</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$groups</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">-></span><span class="default">search</span><span class="keyword">(</span><span class="default">sprintf</span><span class="keyword">(</span><span class="default">$authLDAPGroupFilter</span><span class="keyword">,</span><span class="default"> </span><span class="default">$username</span><span class="keyword">)</span><span class="keyword">,</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="default">$authLDAPGroupAttr</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="493"></a><a href="#493">493</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">catch</span><span class="default"> </span><span class="keyword">(</span><span class="default">Exception</span><span class="default"> </span><span class="default">$e</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="494"></a><a href="#494">494</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Exception getting LDAP group attributes: '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$e</span><span class="default">-></span><span class="default">getMessage</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="495"></a><a href="#495">495</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="496"></a><a href="#496">496</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="497"></a><a href="#497">497</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="498"></a><a href="#498">498</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$grp</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="499"></a><a href="#499">499</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">for</span><span class="default"> </span><span class="keyword">(</span><span class="default">$i</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">0</span><span class="keyword">;</span><span class="default"> </span><span class="default">$i</span><span class="default"> </span><span class="keyword"><</span><span class="default"> </span><span class="default">$groups</span><span class="default"> </span><span class="keyword">[</span><span class="default">'count'</span><span class="keyword">]</span><span class="keyword">;</span><span class="default"> </span><span class="default">$i</span><span class="default">++</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="500"></a><a href="#500">500</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">for</span><span class="default"> </span><span class="keyword">(</span><span class="default">$k</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">0</span><span class="keyword">;</span><span class="default"> </span><span class="default">$k</span><span class="default"> </span><span class="keyword"><</span><span class="default"> </span><span class="default">$groups</span><span class="keyword">[</span><span class="default">$i</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPGroupAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">'count'</span><span class="keyword">]</span><span class="keyword">;</span><span class="default"> </span><span class="default">$k</span><span class="default">++</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="501"></a><a href="#501">501</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$grp</span><span class="keyword">[</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$groups</span><span class="keyword">[</span><span class="default">$i</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">strtolower</span><span class="keyword">(</span><span class="default">$authLDAPGroupAttr</span><span class="keyword">)</span><span class="keyword">]</span><span class="keyword">[</span><span class="default">$k</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="502"></a><a href="#502">502</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="503"></a><a href="#503">503</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="504"></a><a href="#504">504</a></div></td><td class="codeLine"><span class="default"> </span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="505"></a><a href="#505">505</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP groups: '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">json_encode</span><span class="keyword">(</span><span class="default">$grp</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="506"></a><a href="#506">506</a></div></td><td class="codeLine"><span class="default"> </span></td></tr>
|
|
<tr><td><div align="right"><a name="507"></a><a href="#507">507</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// Check whether the user is member of one of the groups that are</span></td></tr>
|
|
<tr><td><div align="right"><a name="508"></a><a href="#508">508</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// allowed acces to the blog. If the user is not member of one of</span></td></tr>
|
|
<tr><td><div align="right"><a name="509"></a><a href="#509">509</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// The groups throw her out! ;-)</span></td></tr>
|
|
<tr><td><div align="right"><a name="510"></a><a href="#510">510</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// If the user is member of more than one group only the first one</span></td></tr>
|
|
<tr><td><div align="right"><a name="511"></a><a href="#511">511</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// will be taken into account!</span></td></tr>
|
|
<tr><td><div align="right"><a name="512"></a><a href="#512">512</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="513"></a><a href="#513">513</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$role</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">''</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="514"></a><a href="#514">514</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">foreach</span><span class="default"> </span><span class="keyword">(</span><span class="default">$authLDAPGroups</span><span class="default"> </span><span class="keyword">as</span><span class="default"> </span><span class="default">$key</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">$val</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="515"></a><a href="#515">515</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$currentGroup</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">explode</span><span class="keyword">(</span><span class="default">$authLDAPGroupSeparator</span><span class="keyword">,</span><span class="default"> </span><span class="default">$val</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="516"></a><a href="#516">516</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// Remove whitespaces around the group-ID</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="517"></a><a href="#517">517</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$currentGroup</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">array_map</span><span class="keyword">(</span><span class="default">'trim'</span><span class="keyword">,</span><span class="default"> </span><span class="default">$currentGroup</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="518"></a><a href="#518">518</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">0</span><span class="default"> </span><span class="keyword"><</span><span class="default"> </span><span class="default">count</span><span class="keyword">(</span><span class="default">array_intersect</span><span class="keyword">(</span><span class="default">$currentGroup</span><span class="keyword">,</span><span class="default"> </span><span class="default">$grp</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="519"></a><a href="#519">519</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$role</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$key</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="520"></a><a href="#520">520</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">break</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="521"></a><a href="#521">521</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="522"></a><a href="#522">522</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="523"></a><a href="#523">523</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="524"></a><a href="#524">524</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="string">"</span><span class="string">Role from LDAP group: </span><span class="string">{</span><span class="string">$role</span><span class="keyword">}</span><span class="string">"</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="525"></a><a href="#525">525</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$role</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="526"></a><a href="#526">526</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="527"></a><a href="#527">527</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="528"></a><a href="#528">528</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="529"></a><a href="#529">529</a></div></td><td class="codeLine"><span class="comment"> * This function disables the password-change fields in the users preferences.</span></td></tr>
|
|
<tr><td><div align="right"><a name="530"></a><a href="#530">530</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="531"></a><a href="#531">531</a></div></td><td class="codeLine"><span class="comment"> * It does not make sense to authenticate via LDAP and then allow the user to</span></td></tr>
|
|
<tr><td><div align="right"><a name="532"></a><a href="#532">532</a></div></td><td class="codeLine"><span class="comment"> * change the password only in the wordpress database. And changing the password</span></td></tr>
|
|
<tr><td><div align="right"><a name="533"></a><a href="#533">533</a></div></td><td class="codeLine"><span class="comment"> * LDAP-wide can not be the scope of Wordpress!</span></td></tr>
|
|
<tr><td><div align="right"><a name="534"></a><a href="#534">534</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="535"></a><a href="#535">535</a></div></td><td class="codeLine"><span class="comment"> * Whether the user is an LDAP-User or not is determined using the authLDAP-Flag</span></td></tr>
|
|
<tr><td><div align="right"><a name="536"></a><a href="#536">536</a></div></td><td class="codeLine"><span class="comment"> * of the users meta-informations</span></td></tr>
|
|
<tr><td><div align="right"><a name="537"></a><a href="#537">537</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="538"></a><a href="#538">538</a></div></td><td class="codeLine"><span class="comment"> * @return false, if the user whose prefs are viewed is an LDAP-User, true if</span></td></tr>
|
|
<tr><td><div align="right"><a name="539"></a><a href="#539">539</a></div></td><td class="codeLine"><span class="comment"> * he isn't</span></td></tr>
|
|
<tr><td><div align="right"><a name="540"></a><a href="#540">540</a></div></td><td class="codeLine"><span class="comment"> * @conf boolean authLDAP</span></td></tr>
|
|
<tr><td><div align="right"><a name="541"></a><a href="#541">541</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="542"></a><a href="#542">542</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_show_password_fields</span><span class="keyword">(</span><span class="default">$return</span><span class="keyword">,</span><span class="default"> </span><span class="default">$user</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="543"></a><a href="#543">543</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="544"></a><a href="#544">544</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default"> </span><span class="default">$user</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="545"></a><a href="#545">545</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">true</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="546"></a><a href="#546">546</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="547"></a><a href="#547">547</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="548"></a><a href="#548">548</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">get_user_meta</span><span class="keyword">(</span><span class="default">$user</span><span class="default">-></span><span class="default">ID</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLDAP'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="549"></a><a href="#549">549</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="550"></a><a href="#550">550</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="551"></a><a href="#551">551</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="552"></a><a href="#552">552</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$return</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="553"></a><a href="#553">553</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="554"></a><a href="#554">554</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="555"></a><a href="#555">555</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="556"></a><a href="#556">556</a></div></td><td class="codeLine"><span class="comment"> * This function disables the password reset for a user.</span></td></tr>
|
|
<tr><td><div align="right"><a name="557"></a><a href="#557">557</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="558"></a><a href="#558">558</a></div></td><td class="codeLine"><span class="comment"> * It does not make sense to authenticate via LDAP and then allow the user to</span></td></tr>
|
|
<tr><td><div align="right"><a name="559"></a><a href="#559">559</a></div></td><td class="codeLine"><span class="comment"> * reset the password only in the wordpress database. And changing the password</span></td></tr>
|
|
<tr><td><div align="right"><a name="560"></a><a href="#560">560</a></div></td><td class="codeLine"><span class="comment"> * LDAP-wide can not be the scope of Wordpress!</span></td></tr>
|
|
<tr><td><div align="right"><a name="561"></a><a href="#561">561</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="562"></a><a href="#562">562</a></div></td><td class="codeLine"><span class="comment"> * Whether the user is an LDAP-User or not is determined using the authLDAP-Flag</span></td></tr>
|
|
<tr><td><div align="right"><a name="563"></a><a href="#563">563</a></div></td><td class="codeLine"><span class="comment"> * of the users meta-informations</span></td></tr>
|
|
<tr><td><div align="right"><a name="564"></a><a href="#564">564</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="565"></a><a href="#565">565</a></div></td><td class="codeLine"><span class="comment"> * @author chaplina (https://github.com/chaplina)</span></td></tr>
|
|
<tr><td><div align="right"><a name="566"></a><a href="#566">566</a></div></td><td class="codeLine"><span class="comment"> * @conf boolean authLDAP</span></td></tr>
|
|
<tr><td><div align="right"><a name="567"></a><a href="#567">567</a></div></td><td class="codeLine"><span class="comment"> * @return false, if the user is an LDAP-User, true if he isn't</span></td></tr>
|
|
<tr><td><div align="right"><a name="568"></a><a href="#568">568</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="569"></a><a href="#569">569</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_allow_password_reset</span><span class="keyword">(</span><span class="default">$return</span><span class="keyword">,</span><span class="default"> </span><span class="default">$userid</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="570"></a><a href="#570">570</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="571"></a><a href="#571">571</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="keyword">(</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$userid</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="572"></a><a href="#572">572</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">true</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="573"></a><a href="#573">573</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="574"></a><a href="#574">574</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="575"></a><a href="#575">575</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">get_user_meta</span><span class="keyword">(</span><span class="default">$userid</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLDAP'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="576"></a><a href="#576">576</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="577"></a><a href="#577">577</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="578"></a><a href="#578">578</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$return</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="579"></a><a href="#579">579</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="580"></a><a href="#580">580</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="581"></a><a href="#581">581</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="582"></a><a href="#582">582</a></div></td><td class="codeLine"><span class="comment"> * Sort the given roles by number of capabilities</span></td></tr>
|
|
<tr><td><div align="right"><a name="583"></a><a href="#583">583</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="584"></a><a href="#584">584</a></div></td><td class="codeLine"><span class="comment"> * @param array $roles</span></td></tr>
|
|
<tr><td><div align="right"><a name="585"></a><a href="#585">585</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="586"></a><a href="#586">586</a></div></td><td class="codeLine"><span class="comment"> * @return array</span></td></tr>
|
|
<tr><td><div align="right"><a name="587"></a><a href="#587">587</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="588"></a><a href="#588">588</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_sort_roles_by_capabilities</span><span class="keyword">(</span><span class="default">$roles</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="589"></a><a href="#589">589</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="590"></a><a href="#590">590</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">global</span><span class="default"> </span><span class="default">$wpdb</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="591"></a><a href="#591">591</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$myRoles</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">get_option</span><span class="keyword">(</span><span class="default">$wpdb</span><span class="default">-></span><span class="default">get_blog_prefix</span><span class="keyword">(</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">'user_roles'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="592"></a><a href="#592">592</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="593"></a><a href="#593">593</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">print_r</span><span class="keyword">(</span><span class="default">$roles</span><span class="keyword">,</span><span class="default"> </span><span class="default">true</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="594"></a><a href="#594">594</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">uasort</span><span class="keyword">(</span><span class="default">$myRoles</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLdap_sortByCapabilitycount'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="595"></a><a href="#595">595</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="596"></a><a href="#596">596</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$return</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="597"></a><a href="#597">597</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="598"></a><a href="#598">598</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">foreach</span><span class="default"> </span><span class="keyword">(</span><span class="default">$myRoles</span><span class="default"> </span><span class="keyword">as</span><span class="default"> </span><span class="default">$key</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">$role</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="599"></a><a href="#599">599</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$roles</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="600"></a><a href="#600">600</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$return</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$roles</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="601"></a><a href="#601">601</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="602"></a><a href="#602">602</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="603"></a><a href="#603">603</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="604"></a><a href="#604">604</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">print_r</span><span class="keyword">(</span><span class="default">$return</span><span class="keyword">,</span><span class="default"> </span><span class="default">true</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="605"></a><a href="#605">605</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$return</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="606"></a><a href="#606">606</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="607"></a><a href="#607">607</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="608"></a><a href="#608">608</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="609"></a><a href="#609">609</a></div></td><td class="codeLine"><span class="comment"> * Sort according to the number of capabilities</span></td></tr>
|
|
<tr><td><div align="right"><a name="610"></a><a href="#610">610</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="611"></a><a href="#611">611</a></div></td><td class="codeLine"><span class="comment"> * @param $a</span></td></tr>
|
|
<tr><td><div align="right"><a name="612"></a><a href="#612">612</a></div></td><td class="codeLine"><span class="comment"> * @param $b</span></td></tr>
|
|
<tr><td><div align="right"><a name="613"></a><a href="#613">613</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="614"></a><a href="#614">614</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_sortByCapabilitycount</span><span class="keyword">(</span><span class="default">$a</span><span class="keyword">,</span><span class="default"> </span><span class="default">$b</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="615"></a><a href="#615">615</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="616"></a><a href="#616">616</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">count</span><span class="keyword">(</span><span class="default">$a</span><span class="keyword">[</span><span class="default">'capabilities'</span><span class="keyword">]</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">></span><span class="default"> </span><span class="default">count</span><span class="keyword">(</span><span class="default">$b</span><span class="keyword">[</span><span class="default">'capabilities'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="617"></a><a href="#617">617</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="keyword">-</span><span class="default">1</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="618"></a><a href="#618">618</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="619"></a><a href="#619">619</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">count</span><span class="keyword">(</span><span class="default">$a</span><span class="keyword">[</span><span class="default">'capabilities'</span><span class="keyword">]</span><span class="keyword">)</span><span class="default"> </span><span class="keyword"><</span><span class="default"> </span><span class="default">count</span><span class="keyword">(</span><span class="default">$b</span><span class="keyword">[</span><span class="default">'capabilities'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="620"></a><a href="#620">620</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">1</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="621"></a><a href="#621">621</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="622"></a><a href="#622">622</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="623"></a><a href="#623">623</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">0</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="624"></a><a href="#624">624</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="625"></a><a href="#625">625</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="626"></a><a href="#626">626</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="627"></a><a href="#627">627</a></div></td><td class="codeLine"><span class="comment"> * Load AuthLDAP Options</span></td></tr>
|
|
<tr><td><div align="right"><a name="628"></a><a href="#628">628</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="629"></a><a href="#629">629</a></div></td><td class="codeLine"><span class="comment"> * Sets and stores defaults if options are not up to date</span></td></tr>
|
|
<tr><td><div align="right"><a name="630"></a><a href="#630">630</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="631"></a><a href="#631">631</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_load_options</span><span class="keyword">(</span><span class="default">$reload</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">false</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="632"></a><a href="#632">632</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="633"></a><a href="#633">633</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">static</span><span class="default"> </span><span class="default">$options</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">null</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="634"></a><a href="#634">634</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="635"></a><a href="#635">635</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// the current version for options</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="636"></a><a href="#636">636</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$option_version_plugin</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">1</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="637"></a><a href="#637">637</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="638"></a><a href="#638">638</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">is_null</span><span class="keyword">(</span><span class="default">$options</span><span class="keyword">)</span><span class="default"> </span><span class="default">||</span><span class="default"> </span><span class="default">$reload</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="639"></a><a href="#639">639</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$options</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">get_option</span><span class="keyword">(</span><span class="default">'authLDAPOptions'</span><span class="keyword">,</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="640"></a><a href="#640">640</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="641"></a><a href="#641">641</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="642"></a><a href="#642">642</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// check if option version has changed (or if it's there at all)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="643"></a><a href="#643">643</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$options</span><span class="keyword">[</span><span class="default">'Version'</span><span class="keyword">]</span><span class="keyword">)</span><span class="default"> </span><span class="default">||</span><span class="default"> </span><span class="keyword">(</span><span class="default">$options</span><span class="keyword">[</span><span class="default">'Version'</span><span class="keyword">]</span><span class="default"> </span><span class="default">!=</span><span class="default"> </span><span class="default">$option_version_plugin</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="644"></a><a href="#644">644</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// defaults for all options</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="645"></a><a href="#645">645</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$options_default</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="646"></a><a href="#646">646</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Enabled'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">false</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="647"></a><a href="#647">647</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'CachePW'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">false</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="648"></a><a href="#648">648</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'URI'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="649"></a><a href="#649">649</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Filter'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span><span class="default"> </span><span class="comment">// '(uid=%s)'</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="650"></a><a href="#650">650</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'NameAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span><span class="default"> </span><span class="comment">// 'name'</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="651"></a><a href="#651">651</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'SecName'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="652"></a><a href="#652">652</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'UidAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span><span class="default"> </span><span class="comment">// 'uid'</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="653"></a><a href="#653">653</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'MailAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span><span class="default"> </span><span class="comment">// 'mail'</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="654"></a><a href="#654">654</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'WebAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="655"></a><a href="#655">655</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Groups'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="656"></a><a href="#656">656</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Debug'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">false</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="657"></a><a href="#657">657</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span><span class="default"> </span><span class="comment">// 'gidNumber'</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="658"></a><a href="#658">658</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupFilter'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span><span class="default"> </span><span class="comment">// '(&(objectClass=posixGroup)(memberUid=%s))'</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="659"></a><a href="#659">659</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'DefaultRole'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">''</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="660"></a><a href="#660">660</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupEnable'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">true</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="661"></a><a href="#661">661</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'GroupOverUser'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">true</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="662"></a><a href="#662">662</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'Version'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">$option_version_plugin</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="663"></a><a href="#663">663</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="664"></a><a href="#664">664</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="665"></a><a href="#665">665</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// check if we got a version</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="666"></a><a href="#666">666</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$options</span><span class="keyword">[</span><span class="default">'Version'</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="667"></a><a href="#667">667</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// we just changed to the new option format</span></td></tr>
|
|
<tr><td><div align="right"><a name="668"></a><a href="#668">668</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// read old options, then delete them</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="669"></a><a href="#669">669</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$old_option_new_option</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="670"></a><a href="#670">670</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAP'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'Enabled'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="671"></a><a href="#671">671</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPCachePW'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'CachePW'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="672"></a><a href="#672">672</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPURI'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'URI'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="673"></a><a href="#673">673</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPFilter'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'Filter'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="674"></a><a href="#674">674</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPNameAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'NameAttr'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="675"></a><a href="#675">675</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPSecName'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'SecName'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="676"></a><a href="#676">676</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPUidAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'UidAttr'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="677"></a><a href="#677">677</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPMailAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'MailAttr'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="678"></a><a href="#678">678</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPWebAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'WebAttr'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="679"></a><a href="#679">679</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPGroups'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'Groups'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="680"></a><a href="#680">680</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPDebug'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'Debug'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="681"></a><a href="#681">681</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPGroupAttr'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'GroupAttr'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="682"></a><a href="#682">682</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPGroupFilter'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'GroupFilter'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="683"></a><a href="#683">683</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPDefaultRole'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'DefaultRole'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="684"></a><a href="#684">684</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPGroupEnable'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'GroupEnable'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="685"></a><a href="#685">685</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">'authLDAPGroupOverUser'</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">'GroupOverUser'</span><span class="keyword">,</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="686"></a><a href="#686">686</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="687"></a><a href="#687">687</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">foreach</span><span class="default"> </span><span class="keyword">(</span><span class="default">$old_option_new_option</span><span class="default"> </span><span class="keyword">as</span><span class="default"> </span><span class="default">$old_option</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">$new_option</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="688"></a><a href="#688">688</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$value</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">get_option</span><span class="keyword">(</span><span class="default">$old_option</span><span class="keyword">,</span><span class="default"> </span><span class="default">null</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="689"></a><a href="#689">689</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="default">is_null</span><span class="keyword">(</span><span class="default">$value</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="690"></a><a href="#690">690</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$options</span><span class="keyword">[</span><span class="default">$new_option</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$value</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="691"></a><a href="#691">691</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="692"></a><a href="#692">692</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">delete_option</span><span class="keyword">(</span><span class="default">$old_option</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="693"></a><a href="#693">693</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="694"></a><a href="#694">694</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">delete_option</span><span class="keyword">(</span><span class="default">'authLDAPCookieMarker'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="695"></a><a href="#695">695</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">delete_option</span><span class="keyword">(</span><span class="default">'authLDAPCookierMarker'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="696"></a><a href="#696">696</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="697"></a><a href="#697">697</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="698"></a><a href="#698">698</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// set default for all options that are missing</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="699"></a><a href="#699">699</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">foreach</span><span class="default"> </span><span class="keyword">(</span><span class="default">$options_default</span><span class="default"> </span><span class="keyword">as</span><span class="default"> </span><span class="default">$key</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">$default</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="700"></a><a href="#700">700</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">!</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$options</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="701"></a><a href="#701">701</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$options</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$default</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="702"></a><a href="#702">702</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="703"></a><a href="#703">703</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="704"></a><a href="#704">704</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="705"></a><a href="#705">705</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// set new version and save</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="706"></a><a href="#706">706</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$options</span><span class="keyword">[</span><span class="default">'Version'</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$option_version_plugin</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="707"></a><a href="#707">707</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">update_option</span><span class="keyword">(</span><span class="default">'authLDAPOptions'</span><span class="keyword">,</span><span class="default"> </span><span class="default">$options</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="708"></a><a href="#708">708</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="709"></a><a href="#709">709</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$options</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="710"></a><a href="#710">710</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="711"></a><a href="#711">711</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="712"></a><a href="#712">712</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="713"></a><a href="#713">713</a></div></td><td class="codeLine"><span class="comment"> * Get an individual option</span></td></tr>
|
|
<tr><td><div align="right"><a name="714"></a><a href="#714">714</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="715"></a><a href="#715">715</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_get_option</span><span class="keyword">(</span><span class="default">$optionname</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="716"></a><a href="#716">716</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="717"></a><a href="#717">717</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$options</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_load_options</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="718"></a><a href="#718">718</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="keyword">isset</span><span class="keyword">(</span><span class="default">$options</span><span class="keyword">[</span><span class="default">$optionname</span><span class="keyword">]</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="719"></a><a href="#719">719</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$options</span><span class="keyword">[</span><span class="default">$optionname</span><span class="keyword">]</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="720"></a><a href="#720">720</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">else</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="721"></a><a href="#721">721</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'option name invalid: '</span><span class="default"> </span><span class="keyword">.</span><span class="default"> </span><span class="default">$optionname</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="722"></a><a href="#722">722</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">null</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="723"></a><a href="#723">723</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="724"></a><a href="#724">724</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="725"></a><a href="#725">725</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="726"></a><a href="#726">726</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="727"></a><a href="#727">727</a></div></td><td class="codeLine"><span class="comment"> * Set new options</span></td></tr>
|
|
<tr><td><div align="right"><a name="728"></a><a href="#728">728</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="729"></a><a href="#729">729</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_set_options</span><span class="keyword">(</span><span class="default">$new_options</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="keyword">array</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="730"></a><a href="#730">730</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="731"></a><a href="#731">731</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// initialize the options with what we currently have</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="732"></a><a href="#732">732</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$options</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">authLdap_load_options</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="733"></a><a href="#733">733</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="734"></a><a href="#734">734</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// set the new options supplied</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="735"></a><a href="#735">735</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">foreach</span><span class="default"> </span><span class="keyword">(</span><span class="default">$new_options</span><span class="default"> </span><span class="keyword">as</span><span class="default"> </span><span class="default">$key</span><span class="default"> </span><span class="default">=></span><span class="default"> </span><span class="default">$value</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="736"></a><a href="#736">736</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">$options</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="default"> </span><span class="keyword">=</span><span class="default"> </span><span class="default">$value</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="737"></a><a href="#737">737</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="738"></a><a href="#738">738</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="739"></a><a href="#739">739</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// store options</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="740"></a><a href="#740">740</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">update_option</span><span class="keyword">(</span><span class="default">'authLDAPOptions'</span><span class="keyword">,</span><span class="default"> </span><span class="default">$options</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="741"></a><a href="#741">741</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// reload the option cache</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="742"></a><a href="#742">742</a></div></td><td class="codeLine"><span class="default"> </span><span class="default">authLdap_load_options</span><span class="keyword">(</span><span class="default">true</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="743"></a><a href="#743">743</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="744"></a><a href="#744">744</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">true</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="745"></a><a href="#745">745</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span><span class="default"> </span><span class="keyword">else</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr><td><div align="right"><a name="746"></a><a href="#746">746</a></div></td><td class="codeLine"><span class="default"> </span><span class="comment">// could not set options</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="747"></a><a href="#747">747</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="748"></a><a href="#748">748</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="749"></a><a href="#749">749</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="750"></a><a href="#750">750</a></div></td><td class="codeLine"></td></tr>
|
|
<tr><td><div align="right"><a name="751"></a><a href="#751">751</a></div></td><td class="codeLine"><span class="comment">/**</span></td></tr>
|
|
<tr><td><div align="right"><a name="752"></a><a href="#752">752</a></div></td><td class="codeLine"><span class="comment"> * Do not send an email after changing the password or the email of the user!</span></td></tr>
|
|
<tr><td><div align="right"><a name="753"></a><a href="#753">753</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="754"></a><a href="#754">754</a></div></td><td class="codeLine"><span class="comment"> * @param boolean $result The initial resturn value</span></td></tr>
|
|
<tr><td><div align="right"><a name="755"></a><a href="#755">755</a></div></td><td class="codeLine"><span class="comment"> * @param array $user The old userdata</span></td></tr>
|
|
<tr><td><div align="right"><a name="756"></a><a href="#756">756</a></div></td><td class="codeLine"><span class="comment"> * @param array $newUserData The changed userdata</span></td></tr>
|
|
<tr><td><div align="right"><a name="757"></a><a href="#757">757</a></div></td><td class="codeLine"><span class="comment"> *</span></td></tr>
|
|
<tr><td><div align="right"><a name="758"></a><a href="#758">758</a></div></td><td class="codeLine"><span class="comment"> * @return bool</span></td></tr>
|
|
<tr><td><div align="right"><a name="759"></a><a href="#759">759</a></div></td><td class="codeLine"><span class="comment"> */</span></td></tr>
|
|
<tr><td><div align="right"><a name="760"></a><a href="#760">760</a></div></td><td class="codeLine"><span class="keyword">function</span><span class="default"> </span><span class="default">authLdap_send_change_email</span><span class="keyword">(</span><span class="default">$result</span><span class="keyword">,</span><span class="default"> </span><span class="default">$user</span><span class="keyword">,</span><span class="default"> </span><span class="default">$newUserData</span><span class="keyword">)</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="761"></a><a href="#761">761</a></div></td><td class="codeLine"><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="762"></a><a href="#762">762</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">if</span><span class="default"> </span><span class="keyword">(</span><span class="default">get_usermeta</span><span class="keyword">(</span><span class="default">$user</span><span class="keyword">[</span><span class="default">'ID'</span><span class="keyword">]</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLDAP'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default"> </span><span class="keyword">{</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="763"></a><a href="#763">763</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">false</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="764"></a><a href="#764">764</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="765"></a><a href="#765">765</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="766"></a><a href="#766">766</a></div></td><td class="codeLine"><span class="default"> </span><span class="keyword">return</span><span class="default"> </span><span class="default">$result</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="767"></a><a href="#767">767</a></div></td><td class="codeLine"><span class="keyword">}</span></td></tr>
|
|
<tr><td><div align="right"><a name="768"></a><a href="#768">768</a></div></td><td class="codeLine"></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="769"></a><a href="#769">769</a></div></td><td class="codeLine"><span class="default">add_action</span><span class="keyword">(</span><span class="default">'admin_menu'</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLdap_addmenu'</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="770"></a><a href="#770">770</a></div></td><td class="codeLine"><span class="default">add_filter</span><span class="keyword">(</span><span class="default">'show_password_fields'</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLdap_show_password_fields'</span><span class="keyword">,</span><span class="default"> </span><span class="default">10</span><span class="keyword">,</span><span class="default"> </span><span class="default">2</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="771"></a><a href="#771">771</a></div></td><td class="codeLine"><span class="default">add_filter</span><span class="keyword">(</span><span class="default">'allow_password_reset'</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLdap_allow_password_reset'</span><span class="keyword">,</span><span class="default"> </span><span class="default">10</span><span class="keyword">,</span><span class="default"> </span><span class="default">2</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="772"></a><a href="#772">772</a></div></td><td class="codeLine"><span class="default">add_filter</span><span class="keyword">(</span><span class="default">'authenticate'</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLdap_login'</span><span class="keyword">,</span><span class="default"> </span><span class="default">10</span><span class="keyword">,</span><span class="default"> </span><span class="default">3</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr><td><div align="right"><a name="773"></a><a href="#773">773</a></div></td><td class="codeLine"><span class="comment">/** This only works from WP 4.3.0 on */</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="774"></a><a href="#774">774</a></div></td><td class="codeLine"><span class="default">add_filter</span><span class="keyword">(</span><span class="default">'send_password_change_email'</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLdap_send_change_email'</span><span class="keyword">,</span><span class="default"> </span><span class="default">10</span><span class="keyword">,</span><span class="default"> </span><span class="default">3</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
<tr class="danger"><td><div align="right"><a name="775"></a><a href="#775">775</a></div></td><td class="codeLine"><span class="default">add_filter</span><span class="keyword">(</span><span class="default">'send_email_change_email'</span><span class="keyword">,</span><span class="default"> </span><span class="default">'authLdap_send_change_email'</span><span class="keyword">,</span><span class="default"> </span><span class="default">10</span><span class="keyword">,</span><span class="default"> </span><span class="default">3</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
|
|
|
|
</tbody>
|
|
</table>
|
|
<footer>
|
|
<hr/>
|
|
<h4>Legend</h4>
|
|
<p>
|
|
<span class="success"><strong>Executed</strong></span>
|
|
<span class="danger"><strong>Not Executed</strong></span>
|
|
<span class="warning"><strong>Dead Code</strong></span>
|
|
</p>
|
|
<p>
|
|
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 4.0.0</a> using <a href="https://secure.php.net/" target="_top">PHP 7.0.6</a> with <a href="https://xdebug.org/">Xdebug 2.4.0</a> at Wed Jun 8 5:43:14 UTC 2016.</small>
|
|
</p>
|
|
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
|
|
</footer>
|
|
</div>
|
|
<script src="js/jquery.min.js" type="text/javascript"></script>
|
|
<script src="js/bootstrap.min.js" type="text/javascript"></script>
|
|
<script src="js/holder.min.js" type="text/javascript"></script>
|
|
<script type="text/javascript">
|
|
$(function() {
|
|
var $window = $(window)
|
|
, $top_link = $('#toplink')
|
|
, $body = $('body, html')
|
|
, offset = $('#code').offset().top;
|
|
|
|
$top_link.hide().click(function(event) {
|
|
event.preventDefault();
|
|
$body.animate({scrollTop:0}, 800);
|
|
});
|
|
|
|
$window.scroll(function() {
|
|
if($window.scrollTop() > offset) {
|
|
$top_link.fadeIn();
|
|
} else {
|
|
$top_link.fadeOut();
|
|
}
|
|
}).scroll();
|
|
|
|
$('.popin').popover({trigger: 'hover'});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|