laipower/wp-content/plugins/authldap/patchcoverage/authLdap.php.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>&nbsp;</td>
<td colspan="10"><div align="center"><strong>Code Coverage</strong></div></td>
</tr>
<tr>
<td>&nbsp;</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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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&nbsp;/&nbsp;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">&lt;?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&nbsp;Name:&nbsp;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&nbsp;URI:&nbsp;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:&nbsp;This&nbsp;plugin&nbsp;allows&nbsp;you&nbsp;to&nbsp;use&nbsp;your&nbsp;existing&nbsp;LDAP&nbsp;as&nbsp;authentication&nbsp;base&nbsp;for&nbsp;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:&nbsp;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:&nbsp;Andreas&nbsp;Heigl&nbsp;&lt;a.heigl@wdv.de&gt;</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&nbsp;URI:&nbsp;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">&nbsp;</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">error_log</span><span class="keyword">(</span><span class="default">'[AuthLDAP]&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$message</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">add_options_page</span><span class="keyword">(</span><span class="default">'AuthLDAP'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">'AuthLDAP'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">'manage_options'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;</span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">$name</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$default</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;</span><span class="keyword">?</span><span class="default">&nbsp;</span><span class="default">$_POST</span><span class="keyword">[</span><span class="default">$name</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">:</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;inclusde&nbsp;style&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;</span><span class="default">plugin_dir_url</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">==</span><span class="default">&nbsp;</span><span class="default">'POST'</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="default">&amp;&amp;</span><span class="default">&nbsp;</span><span class="default">array_key_exists</span><span class="keyword">(</span><span class="default">'ldapOptionsSave'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$_POST</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$new_options</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Enabled'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPAuth'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'CachePW'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPCachePW'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'URI'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Filter'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'NameAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'SecName'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'UidAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'MailAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'WebAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Groups'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroups'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupSeparator'</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroupSeparator'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Debug'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPDebug'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupFilter'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'DefaultRole'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupEnable'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroupEnable'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupOverUser'</span><span class="default">&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">authLdap_get_post</span><span class="keyword">(</span><span class="default">'authLDAPGroupOverUser'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">echo</span><span class="default">&nbsp;</span><span class="default">&quot;&lt;div&nbsp;class='updated'&gt;&lt;p&gt;Saved&nbsp;Options!&lt;/p&gt;&lt;/div&gt;&quot;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">else</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">echo</span><span class="default">&nbsp;</span><span class="default">&quot;&lt;div&nbsp;class='error'&gt;&lt;p&gt;Could&nbsp;not&nbsp;save&nbsp;Options!&lt;/p&gt;&lt;/div&gt;&quot;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Do&nbsp;some&nbsp;initialization&nbsp;for&nbsp;the&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAP</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPCachePW</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPURI</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPFilter</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPNameAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPSecName</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPMailAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPUidAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPWebAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroups</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupSeparator</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPDebug</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupFilter</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPDefaultRole</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupEnable</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupOverUser</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$tChecked</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$authLDAP</span><span class="keyword">)</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">?</span><span class="default">&nbsp;</span><span class="default">'&nbsp;checked=&quot;checked&quot;'</span><span class="default">&nbsp;</span><span class="keyword">:</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$tDebugChecked</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$authLDAPDebug</span><span class="keyword">)</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">?</span><span class="default">&nbsp;</span><span class="default">'&nbsp;checked=&quot;checked&quot;'</span><span class="default">&nbsp;</span><span class="keyword">:</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$tPWChecked</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$authLDAPCachePW</span><span class="keyword">)</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">?</span><span class="default">&nbsp;</span><span class="default">'&nbsp;checked=&quot;checked&quot;'</span><span class="default">&nbsp;</span><span class="keyword">:</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$tGroupChecked</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$authLDAPGroupEnable</span><span class="keyword">)</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">?</span><span class="default">&nbsp;</span><span class="default">'&nbsp;checked=&quot;checked&quot;'</span><span class="default">&nbsp;</span><span class="keyword">:</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$tGroupOverUserChecked</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$authLDAPGroupOverUser</span><span class="keyword">)</span><span class="default">&nbsp;&nbsp;</span><span class="keyword">?</span><span class="default">&nbsp;</span><span class="default">'&nbsp;checked=&quot;checked&quot;'</span><span class="default">&nbsp;</span><span class="keyword">:</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$roles</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$action</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">echo</span><span class="default">&nbsp;</span><span class="default">'&lt;div&nbsp;class=&quot;warning&quot;&gt;The&nbsp;LDAP-Extension&nbsp;is&nbsp;not&nbsp;available&nbsp;on&nbsp;your&nbsp;'</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">'WebServer.&nbsp;Therefore&nbsp;Everything&nbsp;you&nbsp;can&nbsp;alter&nbsp;here&nbsp;does&nbsp;not&nbsp;'</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">'make&nbsp;any&nbsp;sense!&lt;/div&gt;'</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">include</span><span class="default">&nbsp;</span><span class="default">dirname</span><span class="keyword">(</span><span class="default">__FILE__</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;get&nbsp;a&nbsp;LDAP&nbsp;server&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;throws&nbsp;exception&nbsp;if&nbsp;there&nbsp;is&nbsp;a&nbsp;problem&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@return&nbsp;object&nbsp;LDAP&nbsp;server&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;boolean&nbsp;authLDAPDebug&nbsp;true,&nbsp;if&nbsp;debugging&nbsp;should&nbsp;be&nbsp;turned&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPURI&nbsp;LDAP&nbsp;server&nbsp;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">&nbsp;*/</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">static</span><span class="default">&nbsp;</span><span class="default">$_server</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPDebug</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPURI</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//$authLDAPURI&nbsp;=&nbsp;'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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'connect&nbsp;to&nbsp;LDAP&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$_server</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">LDAP</span><span class="keyword">(</span><span class="default">$authLDAPURI</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;This&nbsp;method&nbsp;authenticates&nbsp;a&nbsp;user&nbsp;using&nbsp;either&nbsp;the&nbsp;LDAP&nbsp;or,&nbsp;if&nbsp;LDAP&nbsp;is&nbsp;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">&nbsp;*&nbsp;available,&nbsp;the&nbsp;local&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;For&nbsp;this&nbsp;we&nbsp;store&nbsp;the&nbsp;hashed&nbsp;passwords&nbsp;in&nbsp;the&nbsp;WP_Database&nbsp;to&nbsp;ensure&nbsp;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">&nbsp;*&nbsp;conditions&nbsp;even&nbsp;without&nbsp;an&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@param&nbsp;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">&nbsp;*&nbsp;@param&nbsp;string&nbsp;$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">&nbsp;*&nbsp;@param&nbsp;string&nbsp;$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">&nbsp;*&nbsp;@param&nbsp;boolean&nbsp;$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">&nbsp;*&nbsp;@return&nbsp;boolean&nbsp;true,&nbsp;if&nbsp;login&nbsp;was&nbsp;successfull&nbsp;or&nbsp;false,&nbsp;if&nbsp;it&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;boolean&nbsp;authLDAP&nbsp;true,&nbsp;if&nbsp;authLDAP&nbsp;should&nbsp;be&nbsp;used,&nbsp;false&nbsp;if&nbsp;not.&nbsp;Defaults&nbsp;to&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPFilter&nbsp;LDAP&nbsp;filter&nbsp;to&nbsp;use&nbsp;to&nbsp;find&nbsp;correct&nbsp;user,&nbsp;defaults&nbsp;to&nbsp;'(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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPNameAttr&nbsp;LDAP&nbsp;attribute&nbsp;containing&nbsp;user&nbsp;(display)&nbsp;name,&nbsp;defaults&nbsp;to&nbsp;'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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPSecName&nbsp;LDAP&nbsp;attribute&nbsp;containing&nbsp;second&nbsp;name,&nbsp;defaults&nbsp;to&nbsp;''</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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPMailAttr&nbsp;LDAP&nbsp;attribute&nbsp;containing&nbsp;user&nbsp;e-mail,&nbsp;defaults&nbsp;to&nbsp;'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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPUidAttr&nbsp;LDAP&nbsp;attribute&nbsp;containing&nbsp;user&nbsp;id&nbsp;(the&nbsp;username&nbsp;we&nbsp;log&nbsp;on&nbsp;with),&nbsp;defaults&nbsp;to&nbsp;'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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPWebAttr&nbsp;LDAP&nbsp;attribute&nbsp;containing&nbsp;user&nbsp;website,&nbsp;defaults&nbsp;to&nbsp;''</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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPDefaultRole&nbsp;default&nbsp;role&nbsp;for&nbsp;authenticated&nbsp;user,&nbsp;defaults&nbsp;to&nbsp;''</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">&nbsp;*&nbsp;@conf&nbsp;boolean&nbsp;authLDAPGroupEnable&nbsp;true,&nbsp;if&nbsp;we&nbsp;try&nbsp;to&nbsp;map&nbsp;LDAP&nbsp;groups&nbsp;to&nbsp;Wordpress&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;boolean&nbsp;authLDAPGroupOverUser&nbsp;true,&nbsp;if&nbsp;LDAP&nbsp;Groups&nbsp;have&nbsp;precedence&nbsp;over&nbsp;existing&nbsp;user&nbsp;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">&nbsp;*/</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">&nbsp;</span><span class="default">authLdap_login</span><span class="keyword">(</span><span class="default">$user</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$username</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$password</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$already_md5</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;don't&nbsp;do&nbsp;anything&nbsp;when&nbsp;authLDAP&nbsp;is&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP&nbsp;disabled&nbsp;in&nbsp;AuthLDAP&nbsp;plugin&nbsp;options&nbsp;(use&nbsp;the&nbsp;first&nbsp;option&nbsp;in&nbsp;the&nbsp;AuthLDAP&nbsp;options&nbsp;to&nbsp;enable&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;If&nbsp;the&nbsp;user&nbsp;has&nbsp;already&nbsp;been&nbsp;authenticated&nbsp;(only&nbsp;in&nbsp;that&nbsp;case&nbsp;we&nbsp;get&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;WP_User-Object&nbsp;as&nbsp;$user)&nbsp;we&nbsp;skip&nbsp;LDAP-authentication&nbsp;and&nbsp;simply&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;the&nbsp;existing&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$user</span><span class="default">&nbsp;</span><span class="keyword">instanceof</span><span class="default">&nbsp;</span><span class="default">WP_User</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'User&nbsp;%s&nbsp;has&nbsp;already&nbsp;been&nbsp;authenticated&nbsp;-&nbsp;skipping&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="string">&quot;</span><span class="string">User&nbsp;'</span><span class="string">$username</span><span class="string">'&nbsp;logging&nbsp;in</span><span class="string">&quot;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$username</span><span class="default">&nbsp;</span><span class="default">==</span><span class="default">&nbsp;</span><span class="default">'admin'</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Doing&nbsp;nothing&nbsp;for&nbsp;possible&nbsp;local&nbsp;user&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">global</span><span class="default">&nbsp;</span><span class="default">$wpdb</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">try</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAP</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPFilter</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPNameAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPSecName</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPMailAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPUidAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPWebAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPDefaultRole</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupEnable</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupOverUser</span><span class="default">&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$username</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Username&nbsp;not&nbsp;supplied:&nbsp;return&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$password</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Password&nbsp;not&nbsp;supplied:&nbsp;return&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$error</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">__</span><span class="keyword">(</span><span class="default">'&lt;strong&gt;Error&lt;/strong&gt;:&nbsp;The&nbsp;password&nbsp;field&nbsp;is&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;First&nbsp;check&nbsp;for&nbsp;valid&nbsp;values&nbsp;and&nbsp;set&nbsp;appropriate&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$authLDAPFilter</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPFilter</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$authLDAPNameAttr</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPNameAttr</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$authLDAPMailAttr</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPMailAttr</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$authLDAPUidAttr</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPUidAttr</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;If&nbsp;already_md5&nbsp;is&nbsp;TRUE,&nbsp;then&nbsp;we're&nbsp;getting&nbsp;the&nbsp;user/password&nbsp;from&nbsp;the&nbsp;cookie.&nbsp;As&nbsp;we&nbsp;don't&nbsp;want&nbsp;to&nbsp;store&nbsp;LDAP&nbsp;passwords&nbsp;in&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;form,&nbsp;we've&nbsp;already&nbsp;replaced&nbsp;the&nbsp;password&nbsp;with&nbsp;the&nbsp;hashed&nbsp;username&nbsp;and&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$already_md5</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$password</span><span class="default">&nbsp;</span><span class="default">==</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'cookie&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;No&nbsp;cookie,&nbsp;so&nbsp;have&nbsp;to&nbsp;authenticate&nbsp;them&nbsp;via&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$result</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">try</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'about&nbsp;to&nbsp;do&nbsp;LDAP&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$result</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">-&gt;</span><span class="default">Authenticate</span><span class="keyword">(</span><span class="default">$username</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$password</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">catch</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">Exception</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP&nbsp;authentication&nbsp;failed&nbsp;with&nbsp;exception:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Rebind&nbsp;with&nbsp;the&nbsp;default&nbsp;credentials&nbsp;after&nbsp;the&nbsp;user&nbsp;has&nbsp;been&nbsp;loged&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Otherwise&nbsp;the&nbsp;credentials&nbsp;of&nbsp;the&nbsp;user&nbsp;trying&nbsp;to&nbsp;login&nbsp;will&nbsp;be&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;This&nbsp;fixes&nbsp;#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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">true</span><span class="default">&nbsp;</span><span class="default">!==</span><span class="default">&nbsp;</span><span class="default">$result</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP&nbsp;authentication&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;TODO&nbsp;what&nbsp;to&nbsp;return?&nbsp;WP_User&nbsp;object,&nbsp;true,&nbsp;false,&nbsp;even&nbsp;an&nbsp;WP_Error&nbsp;object...&nbsp;all&nbsp;seem&nbsp;to&nbsp;fall&nbsp;back&nbsp;to&nbsp;normal&nbsp;wp&nbsp;user&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP&nbsp;authentication&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$attributes</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">try</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$attribs</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">sprintf</span><span class="keyword">(</span><span class="default">$authLDAPFilter</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;First&nbsp;get&nbsp;all&nbsp;the&nbsp;relevant&nbsp;group&nbsp;informations&nbsp;so&nbsp;we&nbsp;can&nbsp;see&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;whether&nbsp;have&nbsp;been&nbsp;changes&nbsp;in&nbsp;group&nbsp;association&nbsp;of&nbsp;the&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'could&nbsp;not&nbsp;get&nbsp;user&nbsp;attributes&nbsp;from&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">throw</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">UnexpectedValueException</span><span class="keyword">(</span><span class="default">'dn&nbsp;has&nbsp;not&nbsp;been&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'could&nbsp;not&nbsp;get&nbsp;user&nbsp;attributes&nbsp;from&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">throw</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</span><span class="default">UnexpectedValueException</span><span class="keyword">(</span><span class="default">'The&nbsp;user-ID&nbsp;attribute&nbsp;has&nbsp;not&nbsp;been&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$dn</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$realuid</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">catch</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">Exception</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Exception&nbsp;getting&nbsp;LDAP&nbsp;user:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$uid</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$role</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;we&nbsp;only&nbsp;need&nbsp;this&nbsp;if&nbsp;either&nbsp;LDAP&nbsp;groups&nbsp;are&nbsp;disabled&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;if&nbsp;the&nbsp;WordPress&nbsp;role&nbsp;of&nbsp;the&nbsp;user&nbsp;overrides&nbsp;LDAP&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">$authLDAPGroupEnable</span><span class="default">&nbsp;</span><span class="default">||</span><span class="default">&nbsp;</span><span class="keyword">!</span><span class="default">$authLDAPGroupOverUser</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$role</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;do&nbsp;LDAP&nbsp;group&nbsp;mapping&nbsp;if&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;(if&nbsp;LDAP&nbsp;groups&nbsp;override&nbsp;worpress&nbsp;user&nbsp;role,&nbsp;$role&nbsp;is&nbsp;still&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">&amp;&amp;</span><span class="default">&nbsp;</span><span class="default">$authLDAPGroupEnable</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$role</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">authLdap_groupmap</span><span class="keyword">(</span><span class="default">$realuid</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'role&nbsp;from&nbsp;group&nbsp;mapping:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;if&nbsp;we&nbsp;don't&nbsp;have&nbsp;a&nbsp;role&nbsp;yet,&nbsp;use&nbsp;default&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">&amp;&amp;</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'no&nbsp;role&nbsp;yet,&nbsp;set&nbsp;default&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$role</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Sorry,&nbsp;but&nbsp;you&nbsp;are&nbsp;not&nbsp;in&nbsp;any&nbsp;group&nbsp;that&nbsp;is&nbsp;allowed&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">trigger_error</span><span class="keyword">(</span><span class="default">'no&nbsp;group&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'user&nbsp;is&nbsp;not&nbsp;in&nbsp;any&nbsp;group&nbsp;that&nbsp;is&nbsp;allowed&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">else</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$roles</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;not&nbsp;sure&nbsp;if&nbsp;this&nbsp;is&nbsp;needed,&nbsp;but&nbsp;it&nbsp;can't&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">$roles</span><span class="default">-&gt;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">trigger_error</span><span class="keyword">(</span><span class="default">'no&nbsp;group&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'role&nbsp;is&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;from&nbsp;here&nbsp;on,&nbsp;the&nbsp;user&nbsp;has&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;now,&nbsp;lets&nbsp;update&nbsp;some&nbsp;user&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_login'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'role'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_email'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;first&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'first_name'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;last&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'last_name'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;mail&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_email'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_url'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;display&nbsp;name,&nbsp;nickname,&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">$user_info</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'display_name'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'nickname'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_nicename'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">$user_info</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'display_name'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="default">.=</span><span class="default">&nbsp;</span><span class="default">'&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'nickname'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="default">.=</span><span class="default">&nbsp;</span><span class="default">'&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_nicename'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="default">.=</span><span class="default">&nbsp;</span><span class="default">'_'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;optionally&nbsp;store&nbsp;the&nbsp;password&nbsp;into&nbsp;the&nbsp;wordpress&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Password&nbsp;will&nbsp;be&nbsp;hashed&nbsp;inside&nbsp;wp_update_user&nbsp;or&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_pass'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">else</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;clear&nbsp;the&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'user_pass'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;add&nbsp;uid&nbsp;if&nbsp;user&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$uid</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;found&nbsp;user&nbsp;in&nbsp;the&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'The&nbsp;LDAP&nbsp;user&nbsp;has&nbsp;an&nbsp;entry&nbsp;in&nbsp;the&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$user_info</span><span class="keyword">[</span><span class="default">'ID'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">unset</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$userid</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">else</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;new&nbsp;wordpress&nbsp;account&nbsp;will&nbsp;be&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'The&nbsp;LDAP&nbsp;user&nbsp;does&nbsp;not&nbsp;have&nbsp;an&nbsp;entry&nbsp;in&nbsp;the&nbsp;WP-Database,&nbsp;a&nbsp;new&nbsp;WP&nbsp;account&nbsp;will&nbsp;be&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$userid</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;if&nbsp;the&nbsp;user&nbsp;exists,&nbsp;wp_insert_user&nbsp;will&nbsp;update&nbsp;the&nbsp;existing&nbsp;user&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Error&nbsp;creating&nbsp;user&nbsp;:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$userid</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">trigger_error</span><span class="keyword">(</span><span class="default">'Error&nbsp;creating&nbsp;user:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$userid</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'user&nbsp;id&nbsp;=&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;flag&nbsp;the&nbsp;user&nbsp;as&nbsp;an&nbsp;ldap&nbsp;user&nbsp;so&nbsp;we&nbsp;can&nbsp;hide&nbsp;the&nbsp;password&nbsp;fields&nbsp;in&nbsp;the&nbsp;user&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">update_user_meta</span><span class="keyword">(</span><span class="default">$userid</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">'authLDAP'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;return&nbsp;a&nbsp;user&nbsp;object&nbsp;upon&nbsp;positive&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</span><span class="keyword">new</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">catch</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">Exception</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">$e</span><span class="default">-&gt;</span><span class="default">getMessage</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">'.&nbsp;Exception&nbsp;thrown&nbsp;in&nbsp;line&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">trigger_error</span><span class="keyword">(</span><span class="default">$e</span><span class="default">-&gt;</span><span class="default">getMessage</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">'.&nbsp;Exception&nbsp;thrown&nbsp;in&nbsp;line&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;*&nbsp;Get&nbsp;user's&nbsp;user&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;Returns&nbsp;null&nbsp;if&nbsp;username&nbsp;not&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@param&nbsp;string&nbsp;$username&nbsp;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">&nbsp;*&nbsp;@param&nbsp;string&nbsp;user&nbsp;id,&nbsp;null&nbsp;if&nbsp;not&nbsp;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">&nbsp;*/</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">global</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;find&nbsp;out&nbsp;whether&nbsp;the&nbsp;user&nbsp;is&nbsp;already&nbsp;present&nbsp;in&nbsp;the&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$uid</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$wpdb</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$wpdb</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="string">&quot;</span><span class="string">SELECT&nbsp;ID&nbsp;FROM&nbsp;</span><span class="string">{</span><span class="string">$wpdb</span><span class="string">-&gt;</span><span class="string">users</span><span class="keyword">}</span><span class="string">&nbsp;WHERE&nbsp;user_login&nbsp;=&nbsp;%s</span><span class="string">&quot;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$uid</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="string">&quot;</span><span class="string">Existing&nbsp;user,&nbsp;uid&nbsp;=&nbsp;</span><span class="string">{</span><span class="string">$uid</span><span class="keyword">}</span><span class="string">&quot;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">else</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;*&nbsp;Get&nbsp;the&nbsp;user's&nbsp;current&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;Returns&nbsp;empty&nbsp;string&nbsp;if&nbsp;not&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@param&nbsp;int&nbsp;$uid&nbsp;wordpress&nbsp;user&nbsp;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">&nbsp;*&nbsp;@return&nbsp;string&nbsp;role,&nbsp;empty&nbsp;if&nbsp;none&nbsp;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">&nbsp;*/</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">global</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">$uid</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$meta_value</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">$wpdb</span><span class="default">-&gt;</span><span class="default">get_var</span><span class="keyword">(</span><span class="string">&quot;</span><span class="string">SELECT&nbsp;meta_value&nbsp;FROM&nbsp;</span><span class="string">{</span><span class="string">$wpdb</span><span class="string">-&gt;</span><span class="string">usermeta</span><span class="keyword">}</span><span class="string">&nbsp;WHERE&nbsp;meta_key&nbsp;=&nbsp;'</span><span class="string">{</span><span class="string">$wpdb</span><span class="string">-&gt;</span><span class="string">prefix</span><span class="keyword">}</span><span class="string">capabilities'&nbsp;AND&nbsp;user_id&nbsp;=&nbsp;</span><span class="string">{</span><span class="string">$uid</span><span class="keyword">}</span><span class="string">&quot;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">$meta_value</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$capabilities</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$roles</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">is_array</span><span class="keyword">(</span><span class="default">$capabilities</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">?</span><span class="default">&nbsp;</span><span class="default">array_keys</span><span class="keyword">(</span><span class="default">$capabilities</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">:</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$role</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="string">&quot;</span><span class="string">Existing&nbsp;user's&nbsp;role:&nbsp;</span><span class="string">{</span><span class="string">$role</span><span class="keyword">}</span><span class="string">&quot;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;Get&nbsp;LDAP&nbsp;groups&nbsp;for&nbsp;user&nbsp;and&nbsp;map&nbsp;to&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@param&nbsp;string&nbsp;$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">&nbsp;*&nbsp;@param&nbsp;string&nbsp;$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">&nbsp;*&nbsp;@return&nbsp;string&nbsp;role,&nbsp;empty&nbsp;string&nbsp;if&nbsp;no&nbsp;mapping&nbsp;found,&nbsp;first&nbsp;found&nbsp;role&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;array&nbsp;authLDAPGroups,&nbsp;associative&nbsp;array,&nbsp;role&nbsp;=&gt;&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPGroupAttr,&nbsp;ldap&nbsp;attribute&nbsp;that&nbsp;holds&nbsp;name&nbsp;of&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;string&nbsp;authLDAPGroupFilter,&nbsp;LDAP&nbsp;filter&nbsp;to&nbsp;find&nbsp;groups.&nbsp;can&nbsp;contain&nbsp;%s&nbsp;and&nbsp;%dn%&nbsp;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">&nbsp;*/</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">&nbsp;</span><span class="default">authLdap_groupmap</span><span class="keyword">(</span><span class="default">$username</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroups</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupAttr</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupFilter</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupSeparator</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$authLDAPGroupAttr</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupAttr</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$authLDAPGroupFilter</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupFilter</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">'(&amp;(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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$authLDAPGroupSeparator</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupSeparator</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">||</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">==</span><span class="default">&nbsp;</span><span class="default">0</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'No&nbsp;group&nbsp;names&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">try</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;To&nbsp;allow&nbsp;searches&nbsp;based&nbsp;on&nbsp;the&nbsp;DN&nbsp;instead&nbsp;of&nbsp;the&nbsp;uid,&nbsp;we&nbsp;replace&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;string&nbsp;%dn%&nbsp;with&nbsp;the&nbsp;users&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$authLDAPGroupFilter</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">str_replace</span><span class="keyword">(</span><span class="default">'%dn%'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">$dn</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Group&nbsp;Filter:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$groups</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">authLdap_get_server</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">-&gt;</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">&nbsp;</span><span class="default">$username</span><span class="keyword">)</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">catch</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">Exception</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'Exception&nbsp;getting&nbsp;LDAP&nbsp;group&nbsp;attributes:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</span><span class="default">$e</span><span class="default">-&gt;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$grp</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">for</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$i</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">0</span><span class="keyword">;</span><span class="default">&nbsp;</span><span class="default">$i</span><span class="default">&nbsp;</span><span class="keyword">&lt;</span><span class="default">&nbsp;</span><span class="default">$groups</span><span class="default">&nbsp;</span><span class="keyword">[</span><span class="default">'count'</span><span class="keyword">]</span><span class="keyword">;</span><span class="default">&nbsp;</span><span class="default">$i</span><span class="default">++</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">for</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$k</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">0</span><span class="keyword">;</span><span class="default">&nbsp;</span><span class="default">$k</span><span class="default">&nbsp;</span><span class="keyword">&lt;</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">$k</span><span class="default">++</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$grp</span><span class="keyword">[</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'LDAP&nbsp;groups:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Check&nbsp;whether&nbsp;the&nbsp;user&nbsp;is&nbsp;member&nbsp;of&nbsp;one&nbsp;of&nbsp;the&nbsp;groups&nbsp;that&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;allowed&nbsp;acces&nbsp;to&nbsp;the&nbsp;blog.&nbsp;If&nbsp;the&nbsp;user&nbsp;is&nbsp;not&nbsp;member&nbsp;of&nbsp;one&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;The&nbsp;groups&nbsp;throw&nbsp;her&nbsp;out!&nbsp;;-)</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;If&nbsp;the&nbsp;user&nbsp;is&nbsp;member&nbsp;of&nbsp;more&nbsp;than&nbsp;one&nbsp;group&nbsp;only&nbsp;the&nbsp;first&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;will&nbsp;be&nbsp;taken&nbsp;into&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$role</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">foreach</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$authLDAPGroups</span><span class="default">&nbsp;</span><span class="keyword">as</span><span class="default">&nbsp;</span><span class="default">$key</span><span class="default">&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">$val</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$currentGroup</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">explode</span><span class="keyword">(</span><span class="default">$authLDAPGroupSeparator</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;Remove&nbsp;whitespaces&nbsp;around&nbsp;the&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$currentGroup</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">array_map</span><span class="keyword">(</span><span class="default">'trim'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">0</span><span class="default">&nbsp;</span><span class="keyword">&lt;</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">$grp</span><span class="keyword">)</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$role</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="string">&quot;</span><span class="string">Role&nbsp;from&nbsp;LDAP&nbsp;group:&nbsp;</span><span class="string">{</span><span class="string">$role</span><span class="keyword">}</span><span class="string">&quot;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;This&nbsp;function&nbsp;disables&nbsp;the&nbsp;password-change&nbsp;fields&nbsp;in&nbsp;the&nbsp;users&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;It&nbsp;does&nbsp;not&nbsp;make&nbsp;sense&nbsp;to&nbsp;authenticate&nbsp;via&nbsp;LDAP&nbsp;and&nbsp;then&nbsp;allow&nbsp;the&nbsp;user&nbsp;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">&nbsp;*&nbsp;change&nbsp;the&nbsp;password&nbsp;only&nbsp;in&nbsp;the&nbsp;wordpress&nbsp;database.&nbsp;And&nbsp;changing&nbsp;the&nbsp;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">&nbsp;*&nbsp;LDAP-wide&nbsp;can&nbsp;not&nbsp;be&nbsp;the&nbsp;scope&nbsp;of&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;Whether&nbsp;the&nbsp;user&nbsp;is&nbsp;an&nbsp;LDAP-User&nbsp;or&nbsp;not&nbsp;is&nbsp;determined&nbsp;using&nbsp;the&nbsp;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">&nbsp;*&nbsp;of&nbsp;the&nbsp;users&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@return&nbsp;false,&nbsp;if&nbsp;the&nbsp;user&nbsp;whose&nbsp;prefs&nbsp;are&nbsp;viewed&nbsp;is&nbsp;an&nbsp;LDAP-User,&nbsp;true&nbsp;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">&nbsp;*&nbsp;he&nbsp;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">&nbsp;*&nbsp;@conf&nbsp;boolean&nbsp;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">&nbsp;*/</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">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="keyword">!</span><span class="default">&nbsp;</span><span class="default">$user</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">get_user_meta</span><span class="keyword">(</span><span class="default">$user</span><span class="default">-&gt;</span><span class="default">ID</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">'authLDAP'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;This&nbsp;function&nbsp;disables&nbsp;the&nbsp;password&nbsp;reset&nbsp;for&nbsp;a&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;It&nbsp;does&nbsp;not&nbsp;make&nbsp;sense&nbsp;to&nbsp;authenticate&nbsp;via&nbsp;LDAP&nbsp;and&nbsp;then&nbsp;allow&nbsp;the&nbsp;user&nbsp;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">&nbsp;*&nbsp;reset&nbsp;the&nbsp;password&nbsp;only&nbsp;in&nbsp;the&nbsp;wordpress&nbsp;database.&nbsp;And&nbsp;changing&nbsp;the&nbsp;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">&nbsp;*&nbsp;LDAP-wide&nbsp;can&nbsp;not&nbsp;be&nbsp;the&nbsp;scope&nbsp;of&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;Whether&nbsp;the&nbsp;user&nbsp;is&nbsp;an&nbsp;LDAP-User&nbsp;or&nbsp;not&nbsp;is&nbsp;determined&nbsp;using&nbsp;the&nbsp;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">&nbsp;*&nbsp;of&nbsp;the&nbsp;users&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@author&nbsp;chaplina&nbsp;(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">&nbsp;*&nbsp;@conf&nbsp;boolean&nbsp;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">&nbsp;*&nbsp;@return&nbsp;false,&nbsp;if&nbsp;the&nbsp;user&nbsp;is&nbsp;an&nbsp;LDAP-User,&nbsp;true&nbsp;if&nbsp;he&nbsp;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">&nbsp;*/</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">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">'authLDAP'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;Sort&nbsp;the&nbsp;given&nbsp;roles&nbsp;by&nbsp;number&nbsp;of&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@param&nbsp;array&nbsp;$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">&nbsp;*</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">&nbsp;*&nbsp;@return&nbsp;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">&nbsp;*/</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">global</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$myRoles</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">get_option</span><span class="keyword">(</span><span class="default">$wpdb</span><span class="default">-&gt;</span><span class="default">get_blog_prefix</span><span class="keyword">(</span><span class="keyword">)</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">uasort</span><span class="keyword">(</span><span class="default">$myRoles</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$return</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">foreach</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$myRoles</span><span class="default">&nbsp;</span><span class="keyword">as</span><span class="default">&nbsp;</span><span class="default">$key</span><span class="default">&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">$role</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$return</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;Sort&nbsp;according&nbsp;to&nbsp;the&nbsp;number&nbsp;of&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@param&nbsp;$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">&nbsp;*&nbsp;@param&nbsp;$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">&nbsp;*/</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">&nbsp;</span><span class="default">authLdap_sortByCapabilitycount</span><span class="keyword">(</span><span class="default">$a</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="keyword">&gt;</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="keyword">&lt;</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;Load&nbsp;AuthLDAP&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;Sets&nbsp;and&nbsp;stores&nbsp;defaults&nbsp;if&nbsp;options&nbsp;are&nbsp;not&nbsp;up&nbsp;to&nbsp;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">&nbsp;*/</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">&nbsp;</span><span class="default">authLdap_load_options</span><span class="keyword">(</span><span class="default">$reload</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">static</span><span class="default">&nbsp;</span><span class="default">$options</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;the&nbsp;current&nbsp;version&nbsp;for&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$option_version_plugin</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">||</span><span class="default">&nbsp;</span><span class="default">$reload</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$options</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">get_option</span><span class="keyword">(</span><span class="default">'authLDAPOptions'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;check&nbsp;if&nbsp;option&nbsp;version&nbsp;has&nbsp;changed&nbsp;(or&nbsp;if&nbsp;it's&nbsp;there&nbsp;at&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">||</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">!=</span><span class="default">&nbsp;</span><span class="default">$option_version_plugin</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;defaults&nbsp;for&nbsp;all&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$options_default</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Enabled'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'CachePW'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'URI'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Filter'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">''</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="comment">//&nbsp;'(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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'NameAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">''</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="comment">//&nbsp;'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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'SecName'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'UidAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">''</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="comment">//&nbsp;'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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'MailAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">''</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="comment">//&nbsp;'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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'WebAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Groups'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Debug'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">''</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="comment">//&nbsp;'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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupFilter'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">''</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="comment">//&nbsp;'(&amp;(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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'DefaultRole'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupEnable'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'GroupOverUser'</span><span class="default">&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'Version'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;check&nbsp;if&nbsp;we&nbsp;got&nbsp;a&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;we&nbsp;just&nbsp;changed&nbsp;to&nbsp;the&nbsp;new&nbsp;option&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;read&nbsp;old&nbsp;options,&nbsp;then&nbsp;delete&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$old_option_new_option</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAP'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPCachePW'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPURI'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPFilter'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPNameAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPSecName'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPUidAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPMailAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPWebAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPGroups'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPDebug'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPGroupAttr'</span><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPGroupFilter'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPDefaultRole'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPGroupEnable'</span><span class="default">&nbsp;&nbsp;&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">'authLDAPGroupOverUser'</span><span class="default">&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">foreach</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$old_option_new_option</span><span class="default">&nbsp;</span><span class="keyword">as</span><span class="default">&nbsp;</span><span class="default">$old_option</span><span class="default">&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">$new_option</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$value</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</span><span class="default">get_option</span><span class="keyword">(</span><span class="default">$old_option</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$options</span><span class="keyword">[</span><span class="default">$new_option</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;set&nbsp;default&nbsp;for&nbsp;all&nbsp;options&nbsp;that&nbsp;are&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">foreach</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$options_default</span><span class="default">&nbsp;</span><span class="keyword">as</span><span class="default">&nbsp;</span><span class="default">$key</span><span class="default">&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">$default</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$options</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;set&nbsp;new&nbsp;version&nbsp;and&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$options</span><span class="keyword">[</span><span class="default">'Version'</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">update_option</span><span class="keyword">(</span><span class="default">'authLDAPOptions'</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;*&nbsp;Get&nbsp;an&nbsp;individual&nbsp;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">&nbsp;*/</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$options</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">else</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">authLdap_debug</span><span class="keyword">(</span><span class="default">'option&nbsp;name&nbsp;invalid:&nbsp;'</span><span class="default">&nbsp;</span><span class="keyword">.</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;*&nbsp;Set&nbsp;new&nbsp;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">&nbsp;*/</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">&nbsp;</span><span class="default">authLdap_set_options</span><span class="keyword">(</span><span class="default">$new_options</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;initialize&nbsp;the&nbsp;options&nbsp;with&nbsp;what&nbsp;we&nbsp;currently&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$options</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;set&nbsp;the&nbsp;new&nbsp;options&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">foreach</span><span class="default">&nbsp;</span><span class="keyword">(</span><span class="default">$new_options</span><span class="default">&nbsp;</span><span class="keyword">as</span><span class="default">&nbsp;</span><span class="default">$key</span><span class="default">&nbsp;</span><span class="default">=&gt;</span><span class="default">&nbsp;</span><span class="default">$value</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">$options</span><span class="keyword">[</span><span class="default">$key</span><span class="keyword">]</span><span class="default">&nbsp;</span><span class="keyword">=</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;store&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">$options</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;reload&nbsp;the&nbsp;option&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span><span class="default">&nbsp;</span><span class="keyword">else</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">//&nbsp;could&nbsp;not&nbsp;set&nbsp;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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;*&nbsp;Do&nbsp;not&nbsp;send&nbsp;an&nbsp;email&nbsp;after&nbsp;changing&nbsp;the&nbsp;password&nbsp;or&nbsp;the&nbsp;email&nbsp;of&nbsp;the&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@param&nbsp;boolean&nbsp;$result&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;initial&nbsp;resturn&nbsp;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">&nbsp;*&nbsp;@param&nbsp;array&nbsp;&nbsp;&nbsp;$user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;old&nbsp;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">&nbsp;*&nbsp;@param&nbsp;array&nbsp;&nbsp;&nbsp;$newUserData&nbsp;The&nbsp;changed&nbsp;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">&nbsp;*</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">&nbsp;*&nbsp;@return&nbsp;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">&nbsp;*/</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">&nbsp;</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">&nbsp;</span><span class="default">$user</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">if</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">'authLDAP'</span><span class="keyword">)</span><span class="keyword">)</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</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">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">return</span><span class="default">&nbsp;</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">&nbsp;</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">&nbsp;</span><span class="default">'authLdap_show_password_fields'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">10</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">'authLdap_allow_password_reset'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">10</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">'authLdap_login'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">10</span><span class="keyword">,</span><span class="default">&nbsp;</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">/**&nbsp;This&nbsp;only&nbsp;works&nbsp;from&nbsp;WP&nbsp;4.3.0&nbsp;on&nbsp;*/</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">&nbsp;</span><span class="default">'authLdap_send_change_email'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">10</span><span class="keyword">,</span><span class="default">&nbsp;</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">&nbsp;</span><span class="default">'authLdap_send_change_email'</span><span class="keyword">,</span><span class="default">&nbsp;</span><span class="default">10</span><span class="keyword">,</span><span class="default">&nbsp;</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>