小编Geo*_*tiz的帖子

PHP LDAP获取用户属性,包括关联组

在当前用户上运行搜索以检索所有属性(包括使用LDAP/PHP在Active Directory中的关联组)的最佳方法是什么?

对于属性,主要只是名字,姓氏和显示名称.

对于关联组,只是用户所属的组,例如memberOf函数.

我尝试了一些选项,但似乎无法获得正确的过滤器/搜索组合,大多数示例都涵盖了检索已知组的用户列表.

我成功绑定后尝试运行它:

$attributes = array("displayname");
$filter = "(&(sAMAccountName=$username))";
$result = ldap_search($ds, $ldapconfig['basedn'], $filter, $attributes);
$entries = ldap_get_entries($ds, $result);
if($entries["count"] > 0){
  echo "displayName: ".$entries[0]['displayname'][0]."<br/>";
 } else {
 echo("msg:'".ldap_error($ds)."'</br>");
 }
Run Code Online (Sandbox Code Playgroud)

返回以下错误:"没有这样的对象".

更新:

这是我尝试的最新块,当我print_r $ info变量时能够得到结果,但是for子句仍然在某处错误.我将basedn更改为dc属性:

$filter="($SearchField=$SearchFor)";
$sr=ldap_search($ds, $basedn, $filter, $LDAPFieldsToFind);
$info = ldap_get_entries($ds, $sr);

if($info["count"] > 0) {
    for ($x=0; $x<$info["count"]; $x++) {
        $sam=$info[$x]['samaccountname'][0];
        $giv=$info[$x]['givenname'][0];
        $tel=$info[$x]['telephonenumber'][0];
        $email=$info[$x]['mail'][0];
        $nam=$info[$x]['cn'][0];
        $dir=$info[$x]['homedirectory'][0];
        $dir=strtolower($dir);
        $pos=strpos($dir,"home");
        $pos=$pos+5;
            if (stristr($sam, $SearchFor) && (strlen($dir) > 8)) {
              print "\nActive Directory says that:\n";
              print "CN …
Run Code Online (Sandbox Code Playgroud)

php ldap active-directory

9
推荐指数
1
解决办法
4万
查看次数

将数字范围映射到0到100

我有可能在+/- 6之间包括0(即6,5,4,3,2,1,0,-1,-2,-3,-4,-5,-6)超出我在PHP中的排名算法.

而不是返回+/- 6,我想返回0到100之间的数字.相关性类似于:

100 = +6
..
75 = +3
..
50 = 0
..
25 = -3
..
0 = -6

考虑到排名算法的输出范围,我将如何在PHP中以编程方式实现此目的?我考虑过以下内容但不确定最佳方法:

function score_alg($x) {
  if ($x == '6')
    return 100;
  if ($x == '3')
    return 75;
  if ($x == '0')
    return 50;
  if ($x == '-3')
    return 25;
  if ($x == '-6')
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

php algorithm math

1
推荐指数
1
解决办法
1071
查看次数

Highcharts 柱形图中点悬停上的粗体 X 轴标签

我使用的是 Highcharts 柱形图 ( http://www.highcharts.com/demo/column-basic ),其中包含超过 50 行数据和 3 个不同的系列。由于此数量和图表宽度限制,x 轴标签靠近并聚集在一起。

当用户将鼠标悬停在图表内的点/列上时,我想加粗或更改 x 轴标签的颜色。我知道您可以绑定到每个点的事件(http://api.highcharts.com/highcharts#plotOptions.column.point.events),但我无法将任何样式更改链接到 x 轴标签由此。这是一个 jsFiddle ( http://bit.ly/SpPvCW ),其中包含该点上的事件。代码块如下所示:

plotOptions: {
        series: {
            point: {
                events: {
                    mouseOver: function() {
                        $reporting.html('x: '+ this.x +', y: '+ this.y);
                    }
                }
            },
            events: {
                mouseOut: function() {                        
                    $reporting.empty();
                }
            }
        }
}
Run Code Online (Sandbox Code Playgroud)

此 jsFiddle ( http://jsfiddle.net/4h7DW/1/ ) 包含一个柱形图,其中 x 轴标签旋转。

xAxis: {
            labels: {
                rotation: -70,
                align: 'right',
                style: {
                    fontSize: '10px',
                    color:'#999',
                    fontFamily: 'Verdana, sans-serif'
                }
            }
}, …
Run Code Online (Sandbox Code Playgroud)

jquery highcharts

0
推荐指数
1
解决办法
5726
查看次数

标签 统计

php ×2

active-directory ×1

algorithm ×1

highcharts ×1

jquery ×1

ldap ×1

math ×1