openldap快速安装部署

以下为官方文档:

1.Get the software

You can obtain a copy of the software by following the instructions on the OpenLDAP Software download page (http://www.openldap.org/software/download/). It is recommended that new users start with the latest release.

2.Unpack the distribution

Pick a directory for the source to live under, change directory to there, and unpack the distribution using the following commands:

gunzip -c openldap-VERSION.tgz | tar xvfB -

then relocate yourself into the distribution directory:
cd openldap-VERSION

You’ll have to replace VERSION with the version name of the release.

3.Review documentation

You should now review the COPYRIGHT, LICENSE, README and INSTALL documents provided with the distribution. The COPYRIGHT and LICENSE provide information on acceptable use, copying, and limitation of warranty of OpenLDAP Software.

You should also review other chapters of this document. In particular, the Building and Installing OpenLDAP Software chapter of this document provides detailed information on prerequisite software and installation procedures.

4.Run configure

You will need to run the provided configure script to configure the distribution for building on your system. The configure script accepts many command line options that enable or disable optional software features. Usually the defaults are okay, but you may want to change them. To get a complete list of options that configure accepts, use the –help option:

./configure --help

However, given that you are using this guide, we’ll assume you are brave enough to just let configure determine what’s best:

./configure

Assuming configure doesn’t dislike your system, you can proceed with building the software. If configure did complain, well, you’ll likely need to go to the Software FAQ Installation section (http://www.openldap.org/faq/?file=8) and/or actually read the Building and Installing OpenLDAP Software chapter of this document.

4.Build the software

The next step is to build the software. This step has two parts, first we construct dependencies and then we compile the software:

make depend
make

Both makes should complete without error.
Test the build.
To ensure a correct build, you should run the test suite (it only takes a few minutes):

make test

Tests which apply to your configuration will run and they should pass. Some tests, such as the replication test, may be skipped.
Install the software.
You are now ready to install the software; this usually requires super-user privileges:

su root -c 'make install'

Everything should now be installed under /usr/local (or whatever installation prefix was used by configure).
Edit the configuration file.
Use your favorite editor to edit the provided slapd.conf(5) example (usually installed as /usr/local/etc/openldap/slapd.conf) to contain a BDB database definition of the form:
database bdb
suffix "dc=,dc="
rootdn "cn=Manager,dc=,dc="
rootpw secret
directory /usr/local/var/openldap-data

Be sure to replace and with the appropriate domain components of your domain name. For example, for example.com, use:

database bdb
suffix "dc=example,dc=com"
rootdn "cn=Manager,dc=example,dc=com"
rootpw secret
directory /usr/local/var/openldap-data

If your domain contains additional components, such as eng.uni.edu.eu, use:

database bdb
suffix "dc=eng,dc=uni,dc=edu,dc=eu"
rootdn "cn=Manager,dc=eng,dc=uni,dc=edu,dc=eu"
rootpw secret
directory /usr/local/var/openldap-data

Details regarding configuring slapd(8) can be found in the slapd.conf(5) manual page and the The slapd Configuration File chapter of this document. Note that the specified directory must exist prior to starting slapd(8).
Start SLAPD.

You are now ready to start the Standalone LDAP Daemon, slapd(8), by running the command:

su root -c /usr/local/libexec/slapd

To check to see if the server is running and configured correctly, you can run a search against it with ldapsearch(1). By default, ldapsearch is installed as /usr/local/bin/ldapsearch:

ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts

Note the use of single quotes around command parameters to prevent special characters from being interpreted by the shell. This should return:
dn:
namingContexts: dc=example,dc=com

Details regarding running slapd(8) can be found in the slapd(8) manual page and the Running slapd chapter of this document.
Add initial entries to your directory.
You can use ldapadd(1) to add entries to your LDAP directory. ldapadd expects input in LDIF form. We’ll do it in two steps:
create an LDIF file
run ldapadd

Use your favorite editor and create an LDIF file that contains:

dn: dc=,dc=
objectclass: dcObject
objectclass: organization
o:
dc:

dn: cn=Manager,dc=,dc=
objectclass: organizationalRole
cn: Manager

Be sure to replace and with the appropriate domain components of your domain name. should be replaced with the name of your organization. When you cut and paste, be sure to trim any leading and trailing whitespace from the example.

dn: dc=example,dc=com
objectclass: dcObject
objectclass: organization
o: Example Company
dc: example

dn: cn=Manager,dc=example,dc=com
objectclass: organizationalRole
cn: Manager

Now, you may run ldapadd(1) to insert these entries into your directory.

ldapadd -x -D "cn=Manager,dc=,dc=" -W -f example.ldif

Be sure to replace and with the appropriate domain components of your domain name. You will be prompted for the “secret” specified in slapd.conf. For example, for example.com, use:

ldapadd -x -D "cn=Manager,dc=example,dc=com" -W -f example.ldif

where example.ldif is the file you created above.
Additional information regarding directory creation can be found in the Database Creation and Maintenance Tools chapter of this document.
See if it works.
Now we’re ready to verify the added entries are in your directory. You can use any LDAP client to do this, but our example uses the ldapsearch(1) tool. Remember to replace dc=example,dc=com with the correct values for your site:

ldapsearch -x -b 'dc=example,dc=com' '(objectclass=*)'

This command will search for and retrieve every entry in the database.
You are now ready to add more entries using ldapadd(1) or another LDAP client, experiment with various configuration options, backend arrangements, etc..


LDAP简介:什么是目录

一、 大纲和目标

LDAP,它的 全称为轻量级目录访问协议。 此文包括以下几方面的内容:

  • 目录的基本定义
  • 理解目录能做什么和不能做什么
  • 2个目录例子
  • 总结使用目录服务的校验表


.htaccess Files for the Rest of Us

.htaccess files are used to configure Apache, as well a range of other web servers. Despite the .htaccess file type extension, they are simply text files that can be edited using any text-editor. In this article, we’ll review what they are, and how you can use them in your projects. Please note that .htaccess files don’t work on Windows-based systems, although they can be edited and uploaded to a compatible web server, and on Linux-based systems they are hidden by default. In order to work with htaccess files locally, to see how they work and generally play around with them, we can use XAMPP (or MAMP) on the Mac – a package that installs and configures Apache, PHP and MySQL. To edit these .htaccess files on Mac, we should use a text editor that allows for the opening of hidden files, such as TextWrangler. A .htaccess file follows the same format as Apache’s main configuration file: httpd.conf. Many of the settings that can be configured using the main configuration file can also be configured with them, and vice versa. A setting configured in an .htaccess file will override the same setting in the main configuration file for the directory which contains the file, as well as all of its subdirectories. They are sometimes referred to as dynamic configuration files because they are read by the server on every request to the directory they are contained within. This means that any changes to an .htaccess file will take effect immediately, without requiring a reboot of the server, unlike changes made to the global configuration file. It also means that you pay a slight performance hit for using them, but they can be useful when you don’t have access to the server’s main configuration file. So now we all know what .htaccess files are, how they are edited and worked with, and some of their pros and cons, let’s look at how they can be used and some of the cool stuff they can do.

Redirects and URL Rewriting

A popular use of .htaccess files is to perform redirects or rewrite URLs. This can help with SEO following a domain name change, or file-structure reorganisation, or can make long unsightly URL more friendly and memorable.

Redirections

A redirection can be as simple as the following:

Redirect 301 ^old\.html$ http://localhost/new.html
This sets the HTTP status code to 301 (moved permanently) and redirects all requests to old.html transparently to new.html. We use a regular expression to match the URL to redirect, which gives us a fine degree of control to ensure only the correct URL is matched for redirection, but adds complexity to the configuration and administration of it. The full URL of the resource being redirected to is required.

Rewrites

A rewrite rule can be as simple as this:

RewriteEngine on
RewriteRule ^old\.html$ new.html
In this example, we just provide a simple file redirect from one file to another, which will also be performed transparently, without changing what is displayed in the address bar. The first directive, RewriteEngine on, simply ensures that the rewrite engine is enabled. In order to update what is displayed in the address bar of the visitor’s browser, we can use the R flag at the end of the RewriteRule e.g.
RewriteRule ^old\.html$ http://hostname/new.html [r=301]
The r flag causes an external redirection which is why the full URL (an example URL here) to the new page is given. We can also specify the status code when using the flag. This causes the address bar to be updated in the visitor’s browser. One of the possible uses for URL rewriting I gave at the start of this section was to make unsightly URLs (containing query-string data) friendlier to visitors and search engines. Let’s see this in action now:
RewriteRule ^products/([^/]+)/([^/]+)/([^/]+) product.php?cat=$1&brand=$2&prod=$3
This rule will allow visitors to use a URL like products/turntables/technics/sl1210, and have it transformed into product.php?cat=turntables&<WBR>brand=technics&prod=sl1210. The parentheses in between the forward slashes in the above regular expression are capturing groups – we can use each of these as $1, $2 and $3 respectively. The [^/]+ character class within the parentheses means match any character except a forward-slash 1 or more times. In practice, URL rewriting can be (and usually is) much more complex and achieve far greater things than this. URL rewriting is better explained using entire tutorials so we won’t look at them in any further detail here.

Serving Custom Error Pages

It’s just not cool to show the default 404 page anymore. Many sites take the opportunity offered by a file not found error to inject a little humour into their site, but at the very least, people expect the 404 page of a site to at least match the style and theme of any other page of the site. Very closely related to URL rewriting, serving a custom error page instead of the standard 404 page is easy with an .htaccess file:

ErrorDocument 404 "/404.html"
That’s all we need; whenever a 404 error occurs, the specified page is displayed. We can configure pages to be displayed for many other server errors too. Restricting Access to Specific Resources Using .htaccess files, we can enable password protection of any file or directory, to all users, or based on things like domain or IP address. This is after all one of their core uses. To prevent access to an entire directory, we would simple create a new .htaccess file, containing the following code:
AuthName "Username and password required"
AuthUserFile /path/to/.htpasswd
Require valid-user
AuthType Basic
This file should then be saved into the directory we wish to protect. The AuthName directive specifies the message to display in the username/password dialog box, the AuthUserFile should be the path to the .htpasswd file. The Require directive specifies that only authenticated users may access the protected file while the AuthType is set to Basic. To protect a specific file, we can wrap the above code in a <files> directive, which specifies the protected file:
<Files "protectedfile.html">
AuthName "Username and password required"
AuthUserFile /path/to/.htpasswd
Require valid-user
AuthType Basic
</Files>
We also require an .htpasswd file for these types of authentication, which contains a colon-separated list of usernames and encrypted passwords required to access the protected resource(s). This file should be saved in a directory that is not accessible to the web. There are a range of services that can be used to generate these files automatically as the password should be stored in encrypted form.

Block Access to Certain Entities

Another use of .htaccess files is to quickly and easily block all requests from an IP address or user-agent. To block a specific IP address, simply add the following directives to your .htaccess file:

order allow,deny
deny from 192.168.0.1
allow from all
The order directive tells Apache in which order to evaluate the allow/deny directives. In this case, allow is evaluated first, then deny. The allow from all directive is evaluated first (even though it appears after the deny directive) and all IPs are allowed, then if the client’s IP matches the one specified in the deny directive, access is forbidden. This lets everyone in except the specified IP. Note that we can also deny access to entire IP blocks by supplying a shorter IP, e.g. 192.168. To deny requests based on user-agent, we could do this:
RewriteCond %{HTTP_USER_AGENT} ^OrangeSpiderRewriteRule ^(.*)$ http://%{REMOTE_ADDR}/$ [r=301,l]
In this example, any client with a HTTP_USER_AGENT string starting with OrangeSpider (a bad bot) is redirected back to the address that it originated from. The regular expression matches any single character (.) zero or more times (*) and redirects to the %{REMOTE_ADDR} environment variable. The l flag we used here instructs Apache to treat this match as the last rule so will not process any others before performing the rewrite.

Force an IE Rendering Mode

Alongside controlling how the server responds to certain requests, we can also do things to the visitor’s browser, such as forcing IE to render pages using a specific rendering engine. For example, we can use the mod_headers module, if it is present, to set the X-UA-Compatible header:

Header set X-UA-Compatible "IE=Edge"
Adding this line to an .htaccess file will instruct IE to use the highest rendering mode available. As demonstrated by HTML5 Boilerplate, we can also avoid setting this header on files that don’t require it by using a <FilesMatch directive like so:
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|xpi|safariextz|vcf)$" >
    Header unset X-UA-Compatible
</FilesMatch>

Implement Caching

Caching is easy to set up and can make your site load faster. Caching is easy to set up and can make your site load faster. ‘Nuff said! By setting a far-future expires date on elements of sites that don’t change very often, we can prevent the browser from requesting unchanged resources on every request. If you’re running your site through Google PageSpeed or Yahoo’s YSlow and you get the message about setting far-future expiry headers, this is how you fix it:

ExpiresActive on
ExpiresActive on
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType video/ogg "access plus 1 month"
ExpiresByType audio/ogg "access plus 1 month"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresByType video/webm "access plus 1 month"
You can add different ExpiresByType directives for any content that is listed in the performance tool you’re using, or anything else that you want to control caching on. The first directive,ExpiresActive on, simply ensures the generation of Expires headers is switched on. These directives depend on Apache having the mod_expires module loaded.

Enabling Compression

Another warning we may get in a performance checker refers to enabling compression, and this is also something we can fix simply by updating our .htaccess file:

FilterDeclare COMPRESS
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css
FilterProvider COMPRESS DEFLATE resp=Content-Type $text/javascript
FilterChain COMPRESS
FilterProtocol COMPRESS DEFLATE change=yes;byteranges=no
This compression scheme works on newer versions of Apache (2.1+) using the mod_filter module. It uses the DEFLATE compression algorithm to compress content based on its response content-type, in this case we specify text/html, text/css and text/javascript (which will likely be the types of files flagged in PageSpeed/Yslow anyhow). In the above example we start out by declaring the filter we wish to use, in this case COMPRESS, using the FilterDeclare directive. We then list the content types we wish to use this filter. TheFilterChain directive then instructs the server to build a filter chain based on the FilterProvider directives we have listed. The FilterProtocol directive allows us to specify options that are applied to the filter chain whenever it is run, the options we need to use are change=yes (the content may be changed by the filter (in this case, compressed)) and byteranges=no (the filter must only be applied to complete files). On older versions of Apache, the mod_deflate module is used to configure DEFLATE compression. We have less control of how the content is filtered in this case, but the directives are simpler:
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/javascript
In this case we just set the compression algorithm using the SetOutputFilter directive, and then specify the content-types we’d like to compress using the AddOutputFilterByTypedirective. Usually your web server will use one of these modules depending on which version of Apache is in use. Generally, you will know this beforehand, but if you are creating a generic .htaccess file that you can use on a variety of sites, or which you may share with other people and therefore you don’t know which modules may be in use, you may wish to use both of the above blocks of code wrapped in <IfModule module_name> directives so that the correct module is used and the server doesn’t throw a 500 error if we try to configure a module that isn’t included. You should be aware that it’s also relatively common for hosts that run a large number of sites from a single box to disable compression as there is a small CPU performance hit for compressing on the server.]

Summary

We looked at some of the most common uses for .htaccess files, and reviewed how we can achieve certain tasks that, as website builders/maintainers, are of particular interest to us. As is the case with any introductory tutorial of this nature, the subjects we’ve covered are presented as introductions to a particular topic. There are many other options and configurations than we have been able to look at, so I’d strongly recommend further reading on any subject that is of particular interest.


webdav简介–开发,原理

概述

      随着对  Internet   标准和网络互操作性的日益关注,作为  HTTP   1.1 的扩展,WebDAVWeb   分布式创作和版本控制)已经成为重要的 Web 通讯协议(有关详细信息,请参阅 IETF RFC 2616)。 WebDAV 规范(有关详细信息,请参阅 IETF RFC 2518)在 1999 年 2 月由 Internet 工程任务组 (IETF) 发布,这中间有 Microsoft 的巨大贡献,以及许多第三方供应商(如  NetscapeXeroxIBM    Novell )的支持。

      由于 WebDAV 与可扩展标记语言 (XML ) 固有的集成,因此它不仅非常依赖 XML,而且已经成为通过 Web 传送 XML 数据的绝佳方法。 但是,在完全了解这些技术所带来的好处之前,一定要先了解什么是 WebDAV,以及它在客户端/服务器体系结构中的用途。

WebDAV的优势

      由于 Web 已经成为 Internet 的基础,因此 HTTP 1.1(超文本传送协议)被证实是用来传输数据的非常灵活的通用协议。 但是,HTTP 存在一些明显的缺点,从而限制了它作为综合的 Internet 通讯协议而被采用: 它非常适合用于查看的静态文档,但不能提供以足够复杂(以便向客户端提供丰富的创作功能)的方式来处理文档的方法。

      例如,当两个作者在未进行交流的情况下同时对一个文档进行更改时,就会出现“更新丢失”问题。 只有由最后一个作者完成、并将修改后的文档重新上载到服务器的修改才会保留下来,另一个作者进行的更改将丢失。

      IETF WebDAV 工作组的目标是,设计一个协议,它提供基于标准的论坛中任何分布式创作工具需要的功能。 当前的 WebDAV 规范 (IETF RFC 2518) 解决协作式创作工具的三个主要问题:

 

 

改写保护。 HTTP 1.1 无法确保客户端可以保护资源,并且可以在其他客户端同时编辑它们的情况下进行更改。 使用 WebDAV,可以通过多种方式来锁定资源,以便让其他客户端知道您对所讨论的资源感兴趣,或者防止其他客户端访问该资源。

资源管理。 HTTP 只能直接访问单个资源。 WebDAV 提供一种更有效地组织数据的方法。 WebDAV 引入了可包含资源  集合 (类似于文件系统文件夹)概念。 通过 WebDAV 进行的资源管理包括如下功能:创建、移动、复制和删除集合,以及集合中的资源或文件。

文档属性。 不同类型的数据具有唯一的属性,这有助于描述数据。 例如,在电子邮件中,这些属性可能是发件人的姓名和接收邮件的时间。 在协作文档中,这些属性可能是文档原始作者的姓名和最后一个编辑者的姓名。 因为人们使用的文档类型各不相同,所以可能的属性类型列表也变得无限大。 XML 是 WebDAV 所需的一种可扩展通讯工具。

WebDAV 请求的格式

 

    HTTP   1.1(请参阅 IETF RFC 2068)提供一组可供客户端与服务器通讯的方法,并指定响应(从服务器返回发出请求的客户端)的格式。 WebDAV 完全采用此规范中的所有方法,扩展其中的一些方法,并引入了其他可提供所描述功能的方法。 WebDAV 中使用的方法包括:

 

 

OptionsHead    Trace 。 主要由应用程序用来发现和跟踪服务器支持和网络行为。

Get 。 检索文档。

Put    Post 。 将文档提交到服务器。

Delete 。 销毁资源或集合。

Mkcol 。 创建集合。

PropFind    PropPatch 。 针对资源和集合检索和设置属性。

Copy    Move 。 管理命名空间上下文中的集合和资源。

Lock    Unlock 。 改写保护。

 

WebDAV 请求的一般结构遵循 HTTP 的格式并且由以下三个组件构成:

 

 

方法 。 声明由客户端执行的方法(上面描述的方法)。

标头 。 描述有关如何完成此任务的指令。

主体 (可选)。 定义用在该指令或其他指令中的数据,用以描述如何完成此方法。

 

在主体组件中,XML   成为整个 WebDAV 结构中的关键元素。


oracle存储过程语法

oracle存储过程语法
1.基本结构
CREATE OR REPLACE PROCEDURE 存储过程名字
(
    参数1 IN NUMBER,
    参数2 IN NUMBER
) IS
变量1 INTEGER :=0;
变量2 DATE;
BEGIN

END 存储过程名字

2.SELECT INTO STATEMENT
  将select查询的结果存入到变量中,可以同时将多个列存储多个变量中,必须有一条
  记录,否则抛出异常(如果没有记录抛出NO_DATA_FOUND)
  例子:
  BEGIN
  SELECT col1,col2 into 变量1,变量2 FROM typestruct where xxx;
  EXCEPTION
  WHEN NO_DATA_FOUND THEN
      xxxx;
  END;
  …

3.IF 判断
  IF V_TEST=1 THEN
    BEGIN
       do something
    END;
  END IF;

4.while 循环
  WHILE V_TEST=1 LOOP
  BEGIN
XXXX
  END;
  END LOOP;

5.变量赋值
  V_TEST := 123;

6.用for in 使用cursor
  …
  IS
  CURSOR cur IS SELECT * FROM xxx;
  BEGIN
FOR cur_result in cur LOOP
  BEGIN
   V_SUM :=cur_result.列名1+cur_result.列名2
  END;
END LOOP;
  END;

7.带参数的cursor
  CURSOR C_USER(C_ID NUMBER) IS SELECT NAME FROM USER WHERE TYPEID=C_ID;
  OPEN C_USER(变量值);
  LOOP
FETCH C_USER INTO V_NAME;
EXIT FETCH C_USER%NOTFOUND;
    do something
  END LOOP;
  CLOSE C_USER;