欢迎各位兄弟 发布技术文章
这里的技术是共享的
512 是启用 ,密码会过期
66048 是启用 ,密码永不过期
从下面的代码中搜 512 66048 就知道怎么回事了
//_get_ad_info时我们保存 _save_ad_to_user 到本网站数据库
function _get_ad_info($gh, $my = false, $diqu = 'js')
{
$ad_info = _get_ad_info_from_ad($gh, array('*'), $diqu);
if (empty($ad_info)) {
return '';
}
$output = '';
if ($my) {
$remote_addr = $_SERVER['REMOTE_ADDR'];
$remote_addr_prefix = substr($remote_addr, 0, (strripos($remote_addr, '.') + 1));
if ($diqu == 'js') {
$arr = array_merge(_get_net_from_dhcp(), array('jsvpn_oa' => array('wireless' => '10.54.30.')));
} else if ($diqu == 'ks') {
$arr = array_merge(_get_net_from_dhcp(), array('jsvpn_oa' => array('wireless' => '10.54.30.')));//这个有待程序改
}
foreach ($arr as $key => $row) {
foreach ($row as $sonKey => $value) {
if (in_array($remote_addr_prefix, $value['wireless']) || in_array($remote_addr_prefix, $value['wired'])) {
if ($diqu == 'js') {
$output .= '电脑使用的网: ' . '<span style="color:red;">' . _get_field_ad_net_level_no_other_js()[$key] . '</span>' . "<br/>";
} else if ($diqu == 'ks') {
$output .= '电脑使用的网: ' . '<span style="color:red;">' . _get_field_ad_net_level_ks()[$key] . '</span>' . "<br/>";
}
break 2;
}
}
}
}
$output .= '工号: ';
$output .= $gh . "<br/>";
$output .= '姓名: ';
$output .= $ad_info['displayname'][0] . "<br/>";
$output .= '邮箱: ';
$output .= $ad_info['mail'][0] . "<br/>";
$output .= '电话: ';
$output .= $ad_info['telephonenumber'][0] . "<br/>";
$output .= '部门: ';
$output .= $ad_info['department'][0] . "<br/>";
$output .= '公司: ';
$output .= $ad_info['company'][0] . "<br/>";
$output .= '权限: ';
$memberofs = $ad_info['memberof'];
unset($memberofs['count']);
$output .= '<ul style="margin-top:5px;">';
if ($diqu == 'js') {
foreach ($memberofs as $key => $value) {
$value = substr($value, 3, stripos($value, ',') - 3);
if (in_array(strtoupper($value), _get_field_ad_net_level_no_other_js())) {
$value = '<span style="color:red;">' . $value . '</span>';
}
$memberofs[$key] = "<li>" . $value . '</li>';
};
} else if ($diqu == 'ks') {
foreach ($memberofs as $key => $value) {
$value = substr($value, 3, stripos($value, ',') - 3);
if (in_array(strtoupper($value), _get_field_ad_net_level_ks())) {
$value = '<span style="color:red;">' . $value . '</span>';
}
$memberofs[$key] = "<li>" . $value . '</li>';
};
}
$memberofs = implode("", $memberofs);
$output .= $memberofs;
$output .= "</ul><br/>";
$output .= '用户帐号控制: ';
switch ($ad_info['useraccountcontrol'][0]) {
case 512:
$useraccountcontrol = '<span style="color:green;">普通启用</span>';
break;
case 514://是禁用的状态
case 546://是禁用的状态
case 66050://是禁用的状态
case 66080://是禁用的状态
case 66082://是禁用的状态
$get = $_GET;
unset($get['q']);
unset($get['unlock']);
$get['useraccountcontrol'] = 66048;
$useraccountcontrol = '<span style="color:red;">禁用</span> '.l('密码永不过期启用',$_GET['q'], array('query' => array_merge($get,array('useraccountcontrol'=>66048))))
.' '.l('普通启用',$_GET['q'], array('query' => array_merge($get,array('useraccountcontrol'=>512))));
break;
case 544:
case 66048:
case 262656:
$useraccountcontrol = '<span style="color:green;">密码永不过期</span>';
break;
default;//似乎除了 512 和 66048 之外 都是 禁用的状态
// $get = $_GET;
// unset($get['q']);
// unset($get['unlock']);
// $get['useraccountcontrol'] = 66048;
// $useraccountcontrol = '<span style="color:red;">禁用</span> '.l('永不过期',$_GET['q'], array('query' => array_merge($get,array('useraccountcontrol'=>66048))))
// .' '.l('启用',$_GET['q'], array('query' => array_merge($get,array('useraccountcontrol'=>512))));
// break;
}
$output .= $useraccountcontrol . "<br/>";
$output .= '锁定:';
if (empty($ad_info['lockouttime'][0])) {
$output .= ' 未锁定!<br/>';
} else {
//这里更新后,执行一下跳转
$get = $_GET;
unset($get['q']);
unset($get['useraccountcontrol']);
$get['unlock'] = 1;
$output .= ' <span style="color:red;">已锁定,锁定时间为: ' . date('Y-m-d H:i:s', intval($ad_info['lockouttime'][0] / (1000 * 10000)) - 11644473600) .
'</span> '.
l('解锁', $_GET['q'], array('query' => $get)).
'<br/>';
}
$output .= '用户创建时间: ';
$output .= date('Y-m-d H:i:s', strtotime(intval($ad_info['whencreated'][0]))) . "<br/>";
$output .= '密码最后修改时间: ';
$pwdlastset_time = intval($ad_info['pwdlastset'][0] / (1000 * 10000)) - 11644473600;
$output .= date('Y-m-d H:i:s', $pwdlastset_time);
$output .= ((time() - $pwdlastset_time) < 48 * 3600) ? ' <span style="color:red;">(最近两天内修改的密码)</span>' : '';
$output .= "<br/>";
$output .= '密码到期时间: ';
if($ad_info['useraccountcontrol'][0] == 66048){
$output .= '<span style="color:green;">永不过期</span>' . " <br/>";
}else{
$expire_time = strtotime("+60 days", $pwdlastset_time);
$curr_time = time();
$diff_days = ceil(($expire_time - $curr_time) / (24 * 3600));
if ($diff_days >= 0) {
if ($diff_days < 7) {
$diff_days = '<span style="color:red;">' . $diff_days . '</span>';
}
$output_days = ' 还有 ' . $diff_days . ' 天过期';
} else {
$diff_days = '<span style="color:red;">' . abs($diff_days) . '</span>';
$output_days = ' 过期了 ' . $diff_days . ' 天';
}
$output .= date('Y-m-d H:i:s', $expire_time) . $output_days . " <br/>";
}
$output .= '最后一次输错密码时间: ';
$output .= date('Y-m-d H:i:s', intval($ad_info['badpasswordtime'][0] / (1000 * 10000)) - 11644473600) . "<br/>";
$output .= 'AD对像最后修改时间: ';
$output .= date('Y-m-d H:i:s', strtotime(intval($ad_info['whenchanged'][0]))) . "<br/>";
$output .= '最后登录时间: ';
$output .= date('Y-m-d H:i:s', intval($ad_info['lastlogon'][0] / (1000 * 10000)) - 11644473600) . "<br/>";
$output .= '帐号到期: ';
if (empty($ad_info['accountexpires'][0])) {
$output .= '永不' . "<br/>";
} else {
$output .= date('Y-m-d H:i:s', intval($ad_info['accountexpires'][0] / (1000 * 10000)) - 11644473600) . "<br/>";
}
$output .= '领导: ';
$output .= $ad_info['manager'][0];
$output .= "<br/>";
$output .= '下属: ';
$directreports = $ad_info['directreports'];
unset($directreports['count']);
$output .= '<ul style="margin-top:5px;">';
foreach ($directreports as $key => $value) {
$directreports[$key] = "<li>" . $value . '</li>';
};
$directreports = implode("", $directreports);
$output .= $directreports;
$output .= '</ul>';
_save_ad_to_user($ad_info, true, $diqu);
return $output;
}