⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1101.html

📁 著名的linux英雄站点的文档打包
💻 HTML
📖 第 1 页 / 共 3 页
字号:
          <TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=103 
          border=0></TD>
          <TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=26 
border=0></TD>
          <TD><IMG height=1 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 
        border=0></TD></TR>
        <TR>
          <TD colSpan=3><A title=linux知识宝库 
            href="index.html" tppabs="http://www.linuxhero.com/docs/index.html"><IMG height=83 
            src="images/header_r1_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c1.gif" width=472 border=0 
            name=header_r1_c1></A></TD>
            <TD colSpan=3>
              <form action="http://www.linuxhero.com/docs/search.html" method=get>
                <table 
                        style="BORDER-RIGHT: #c4c4c4 1px solid; BORDER-TOP: #c4c4c4 1px solid; BORDER-LEFT: #c4c4c4 1px solid; BORDER-BOTTOM: #c4c4c4 1px solid" 
                        cellspacing=0 cellpadding=3 width="95%" border=0 align="center">
                  <tbody> 
                  <tr> 
                    <td noWrap background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif"> 
                      <div align=center><font class=normalfont>搜索文章: 
                        <input type=hidden value=result name=action2>
                          <input type=radio checked value=title name=type>标题 
                          <input type=radio value=content name=type>内容 
                          <input type=image src="images/button_go.gif" tppabs="http://www.linuxhero.com/docs/images/button_go.gif" border=0 name=image2>
                        </font></div>
                    </td>
                  </tr>
                  <tr> 
                    <td noWrap> 
                      <div align="center"> 
                        <input maxlength=100 size=30 name=keyword2>
                      </div>
                    </td>
                  </tr></tbody> 
                </table>
              </form>
            </TD>
            <TD rowSpan=2><IMG src="images/header_r1_c7.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c7.gif" width=26 border=0 name=header_r1_c7></TD>
          <TD><IMG height=83 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 border=0></TD></TR>
        <TR>
          <TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif"><IMG height=22 
            src="images/header_r2_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r2_c1.gif" width=296 border=0 
            name=header_r2_c1></TD>
          <TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colSpan=5>
              <DIV align=right><FONT class=normalfont>当前位置: 
              <A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
              <font color="#FF6699">&gt;&gt;</font>
<A href="type15.html" tppabs="http://www.linuxhero.com/docs/type15.html">网络安全</A>                 | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
            </TD>
          <TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 
        border=0></TD></TR></TBODY></TABLE>
      <TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff 
        border=0>
         <TR>
          <TD>
            <TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
              
              <TR>
                <TD vAlign=top align=middle width="60%">
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" 
                  background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
                    <TBODY>
                    <TR>
                        <TD vAlign=top width="80%"> 
                          <DIV align=center>
                        <FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
                            </FORM>
                        <TABLE cellSpacing=0 cellPadding=0 width="95%" 
                          border=0><TBODY>
                          <TR>
                            <TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif" 
                          height=30></TD></TR></TBODY></TABLE>
                        <TABLE cellSpacing=0 cellPadding=3 width="95%" 
                        align=center border=0>
                          <TBODY>
                          <TR>
                            <TD>
                              <TABLE cellSpacing=0 cellPadding=3 width="100%" 
                              border=0>
                                <TBODY>
                                <TR>
                                      <TD vAlign=top> 
<p><FONT class=normalfont><B><font color=blue>在Windows和UNIX下利用PHP和LDAP进行身份验证</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:keigopan<br>来自:Linux知识宝库<br>联系方式:无名<br><br>我现在的老板曾要求我为企业内部互联网的Web服务提供一种标准的身份验证方法。我遇到的一个主要问题就是我们公司主要使用了两种平台:UNIX和Windows。所以,我的第一个想法并不很成功:它要求每个员工都使用UNIX或者Linux而放弃Windows。<br>
<br>
我认为解决现在的UNIX/Windows问题的最好方法就是利用PHP的LDAP特性。由于LDAP服务器,要求我使用现有的系统,主要指的是一个巨大的Microsoft Exchange Server系统。我非常高兴使用Exchange,它很可靠,而且LDAP特性的使用和配置也极为简单。不过,请你注意:这套方案就身份验证角度来看并不是最安全的。如果有较高等级的安全需求,我强烈建议你采用LDAP和SSL。<br>
<br>
从哪里开始学习<br>
为了让你入门,我给出了一个PHP LDAP函数的清单并对函数的功能给以简要说明。然后,我将演示如何建立到LDAP服务器的连接并验证用户。为了代码简单起见,我将演示PHP连接的功能以及如何绑定到LDAP服务器。<br>
<br>
一对绝配:PHP和LADP<br>
下面是我在例子中将要使用的函数的清单。网上有相关资料。<br>
<br>
ldap_connect—用来连接LDAP服务。<br>
ldap_bind—用来绑定到特定的LDAP目录。<br>
ldap_error—从LDAP服务器上获得错误信息。<br>
ldap_search—用来开始搜索。<br>
ldap_get_entries—从搜索结果中获得多个结果。<br>
ldap_close—关闭LDAP连接。<br>
<br>
现在我在例子中演示如何使用第一个函数(代码清单A)并适当介绍该函数的功能。<br>
<br>
&lt;?php<br>
// LDAP variables<br>
$ldap[‘user’] = ‘uname’;<br>
$ldap[‘pass’] = ‘password’;<br>
$ldap[‘host’] = ‘ldap.example.com’;<br>
$ldap[‘port’] = 389;<br>
$ldap[‘dn’] = ‘cn’.$ldap[‘user’].’,ou=Department,o=Company Name’;<br>
$ldap[‘base’] = ‘’;<br>
<br>
// connecting to ldap<br>
$ldap[‘conn’] = ldap_connect( $ldap[‘host’], $ldap[‘port’] )<br>
or die( “Could not connect to {$ldap[‘host’]}” );<br>
?&gt;<br>
将会返回一个到LDAP服务器的连接(也称为资源,即resource)。ldap_connect函数有两个参数:主机(host)和端口。第一个参数:主机就是LDAP主机名称,第二个参数是LDAP运行的端口。默认情况下,LDAP使用的端口号为389。如果你需要到LDAP服务器的一个安全连接,你可以把参数host改为一个你可以访问的LDAP服务器的URL,如下所示:<br>
<br>
$ldap[‘conn’] = ldap_connect( “ldaps://ldap.example.com” );<br>
<br>
由于你指定了URL而不是服务器名称,在这种方法下,你就不需要使用端口参数了。需要牢记的一点就是确切名称需要与加密套接字协议层证书(the SSL certificate)对应。<br>
<br>
&lt;?php<br>
// LDAP variables<br>
$ldap[‘user’] = ‘uname’;<br>
$ldap[‘pass’] = ‘password’;<br>
$ldap[‘host’] = ‘ldap.example.com’;<br>
$ldap[‘port’] = 389;<br>
$ldap[‘dn’] = ‘cn’.$ldap[‘user’].’,ou=Department,o=Company Name’;<br>
$ldap[‘base’] = ‘’;<br>
<br>
// connecting to ldap<br>
$ldap[‘conn’] = ldap_connect( $ldap[‘host’], $ldap[‘port’] )<br>
or die( “Could not connect to {$ldap[‘host’]}” );<br>
<br>
// binding to ldap<br>
$ldap[‘bind’] = ldap_bind( $ldap[‘conn’], $ldap[‘dn’], $ldap[‘pass’] );<br>
<br>
?&gt;<br>
演示了如何用用户名和口令来绑定到服务器。我创建了一个合适的域名(domain name ,DN)并用用户的口令来合法连接到LDAP。我们通过使用域名和口令就可以让LDAP服务器通过身份认证并允许绑定连接,这样我们就成功的绑定上了。ldap_bind的返回值是一个布尔类型。我们可以根据返回值判断用户的登录证书是否有效。当这个过程结束后,你就可以知道用户身份是否得到了认证。<br>
<br>
如果发生了错误会怎样?调用ldap_error函数是判断发生了什么错误的好方法。ldap_error函数返回了一个字符串,其中包含了LDAP服务器发生的最后错误的信息。<br>
<br>
在<br>
<br>
&lt;?php<br>
// LDAP variables<br>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -