您的位置:首页 > 编程语言 > PHP开发

用PHP输出LDAP查询结果

2014-03-31 18:01 281 查看
    做好Postfix+LDAP后,一直想写个程式,自动抓取LDAP中的邮箱地址,不用手动更改全局邮箱地址再发布,今天终于如愿,主要参考如下网页,在些感谢:

一个漂亮的输出MySql数据库表结构的PHP页面 
http://babyhe.blog.51cto.com/1104064/1118372
使用PHP连接LDAP服务器 http://www.justwinit.cn/post/591/
我的PHP源码:

点击(此处)折叠或打开

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">

<!--

body,table{

        font-size:13px;

}

table{

        table-layout:fixed;

        empty-cells:show;

        border-collapse: collapse;

        margin:0 auto;

  border:1px solid #cad9ea;

}

th{

        height:22px;

  font-size:13px;

  font-weight:bold;

  background-color:#CCCCCC;

  text-align:center;

}

td{

        height:20px;

}

.tableTitle{font-size:14px; font-weight:bold;}

.STYLE1 {color: #FF0000}

</style>

<title>Email Address</title>

</head>

<body>

<div style="margin:0 auto;width:800px; border:1px #006600 solid; font-size:12px; line-height:20px;">

  <div style="width:100%;height:30px; font-size:16px; font-weight:bold; text-align:center;">

  XXXX--郵箱清單<br />

  <font style="font-size:14px; font-weight:normal;"><b><span class="STYLE1">更新時間</span>:</b><?php echo date("Y-m-d h:i:s"); ?></font> </div>

  <?php

  

  $connect_id=ldap_connect("x.x.x.x");

  $result_array=array("cn","mail","mailQuota");

  $search_id=ldap_search($connect_id,"virtualDomain=x.com,o=extmailAccount,dc=x.com", "cn=*",$result_array);

  $result_array = ldap_get_entries($connect_id,$search_id);

  for($i=0;$i<$result_array["count"];$i++)

    {

    $format_array[$i][0]=strtolower($result_array[$i]["cn"][0]);

    $format_array[$i][1]=strtolower($result_array[$i]["mail"][0]);

    $format_array[$i][2]=strtolower($result_array[$i]["mailQuota"][0]);

    }

    sort($format_array);

/* for($row=0;$row<$result_array["count"];$row++)

    {

     //print_r($row); */

  ?>

      <div style="margin:0 auto; width:100%; padding-top:10px;">

      <br/>

      </div>

       <table width="100%" border="1">

            <thead>

         <th width="10">ROW</th>

          <th width="50">姓名</td>

          <th width="100">郵箱地址</td>

         <th width="100">郵箱限額</td>

         </thead>

    <?php

    //    for($i=0;$i<=$row$result_array["count"];$i++)

        for($i=0;$i<=$result_array["count"];$i++)

        {

        $cn=$format_array[$i][0];

        $mail=$format_array[$i][1];

        $quota=$format_array[$i][2];

        ?>

        <tr>

            <td align="center"><?php echo $i ?></td>

            <td align="left"><b><?php echo $cn ?></b></td>

            <td align="left"><?php echo $mail ?></td>

            <td align="left"><?php echo $quota ?></td>

        </tr>

        <?php

        }

        ?>

    </table>

    <?php

    //}

    ldap_close($connect_id);

    ?>

</div>

</body>

</html>

实现效果(遗憾的是邮箱限额未能带出,再确认中):



阅读(9) | 评论(0) | 转发(0) |

0
上一篇:一个漂亮的输出MySql数据库表结构的PHP页面

下一篇:网页自动跳转的5中方法

相关热门文章
天津二手房市近日开始降温 买...

河南省消协提醒买卖二手房警惕...

UBOOT-2012-10在OK6410平台的...

华美远航(北京)投资有限公司...

Accept-Encoding: gzip,deflat...

test123

编写安全代码——小心有符号数...

使用openssl api进行加密解密...

一段自己打印自己的c程序...

sql relay的c++接口

IBM DS3400 盘阵怎么查看是单...

启动auditd时,报错如下,怎么...

CGSL系统中root密码正确,但无...

在CGSL系统中,如何为不同的用...

CGSL系统如何设置交换分区的大...

给主人留下些什么吧!~~

评论热议
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: