ldap连接mysql (openldap-2.4.40 rpm + 操作系统CentOS 6.5标准版)

 

1. 将附件解压到服务器/usr/local/ldap目录下

2. 进入/usr/local/ldap/libdbi目录,安装libdbi依赖库,如果存在老版本,请rpm -e卸载或rpm -Uvh升级老版本

rpm -ivh libdbi-0.8.3-4.el6.x86_64.rpm

rpm -ivh libdbi-devel-0.8.3-4.el6.x86_64.rpm

rpm -ivh libdbi-drivers-0.8.3-5.1.el6.x86_64.rpm

rpm -ivh libdbi-dbd-mysql-0.8.3-5.1.el6.x86_64.rpm

3. 进入/usr/local/ldap/cyrus目录,安装cyrus依赖库,如果存在老版本,rpm -e卸载或rpm -Uvh升级老版本

rpm -ivh cyrus-sasl-lib-2.1.23-15.el6_6.2.x86_64.rpm

rpm -ivh cyrus-sasl-2.1.23-15.el6_6.2.x86_64.rpm

rpm -ivh cyrus-sasl-plain-2.1.23-15.el6_6.2.x86_64.rpm

rpm -ivh cyrus-sasl-devel-2.1.23-15.el6_6.2.x86_64.rpm

4. 进入/usr/local/ldap/unixODBC目录,安装unixODBC和依赖库libtool-ltdl

rpm -ivh libtool-ltdl-2.2.6-15.5.el6.x86_64.rpm

rpm -ivh unixODBC-2.2.14-14.el6.x86_64.rpm

rpm -ivh unixODBC-devel-2.2.14-14.el6.x86_64.rpm

5. 进入/usr/local/ldap/mysql,安装mysql,如果存在老版本,rpm -e卸载或rpm -Uvh升级老版本

rpm -ivh mysql-libs-5.1.73-8.el6_8.x86_64.rpm

rpm -ivh perl-DBD-MySQL-4.013-3.el6.x86_64.rpm

rpm -ivh mysql-5.1.73-8.el6_8.x86_64.rpm

rpm -ivh mysql-server-5.1.73-8.el6_8.x86_64.rpm

rpm -ivh mysql-connector-odbc-5.1.5r1144-7.el6.x86_64.rpm

6. 操作mysql,准备数据

1. 启动mysql

service mysql start

2. 设置mysql密码

mysql_secure_installation

3. 登录mysql

mysql -uroot -p密码

4. 创建用户,创建数据库ldap,赋权

CREATE USER [email protected] IDENTIFIED BY ‘123456‘;

CREATE DATABASE IF NOT EXISTS ldap;

GRANT ALL PRIVILEGES ON ldap.* TO ‘linying‘@‘localhost‘ identified by ‘123456‘;

GRANT ALL PRIVILEGES ON ldap.* TO ‘linying‘@‘127.0.0.1‘ identified by ‘123456‘;

GRANT ALL PRIVILEGES ON *.* TO ‘linying‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;

FLUSH PRIVILEGES;

5. 导入表和测试数据

source /usr/local/ldap/ldap.sql

6. 导入库

cd /usr/share/doc/openldap-servers-sql-2.4.40/rdbms_depend/mysql

mysql -ulinying -p123456 ldap< backsql_create.sql

mysql -ulinying -p123456 ldap< testdb_create.sql

mysql -ulinying -p123456 ldap< testdb_data.sql

mysql -ulinying -p123456 ldap< testdb_metadata.sql

7. 配置/etc/odbc.ini和/etc/odbcinst.ini文件

odbc.ini

     odbcinst.ini(没有修改,默认配置)

8.  测试连接:isql -v ldap

9. 进入/usr/local/ldap/openldap,安装openldap,如果存在openldap老版本先卸载

rpm -ivh openldap-2.4.40-16.el6.x86_64.rpm

rpm -ivh pam_ldap-185-11.el6.x86_64.rpm

rpm -ivh openldap-devel-2.4.40-16.el6.x86_64.rpm

rpm -ivh openldap-servers-2.4.40-16.el6.x86_64.rpm

rpm -ivh openldap-servers-sql-2.4.40-16.el6.x86_64.rpm

rpm -ivh openldap-clients-2.4.40-16.el6.x86_64.rpm

10.配置openldap

1. 设置openldap密码

slappasswd

{SSHA}rJ3sVQ8nJ3Mp5an0UeSm2sTb4XWE3r6J

2.将配置模版拷贝到执行目录

cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf

cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

3.配置vi /etc/openldap/slapd.conf

#

# See slapd.conf(5) for details on configuration options.

# This file should NOT be world readable.

#

include  /etc/openldap/schema/corba.schema

include  /etc/openldap/schema/core.schema

include  /etc/openldap/schema/cosine.schema

include  /etc/openldap/schema/duaconf.schema

include  /etc/openldap/schema/dyngroup.schema

include  /etc/openldap/schema/inetorgperson.schema

include  /etc/openldap/schema/java.schema

include  /etc/openldap/schema/misc.schema

include  /etc/openldap/schema/nis.schema

include  /etc/openldap/schema/openldap.schema

include  /etc/openldap/schema/ppolicy.schema

include  /etc/openldap/schema/collective.schema

# Allow LDAPv2 client connections.  This is NOT the default.

allow bind_v2

# Do not enable referrals until AFTER you have a working directory

# service AND an understanding of referrals.

#referral ldap://root.openldap.org

pidfile  /var/run/openldap/slapd.pid

argsfile /var/run/openldap/slapd.args

# Load dynamic backend modules

# - modulepath is architecture dependent value (32/64-bit system)

# - back_sql.la overlay requires openldap-server-sql package

# - dyngroup.la and dynlist.la cannot be used at the same time

# modulepath /usr/lib/openldap

# modulepath /usr/lib64/openldap

modulepath /usr/lib64/openldap

moduleload back_sql

# moduleload accesslog.la

# moduleload auditlog.la

# moduleload back_sql.la

# moduleload chain.la

# moduleload collect.la

# moduleload constraint.la

# moduleload dds.la

# moduleload deref.la

# moduleload dyngroup.la

# moduleload dynlist.la

# moduleload memberof.la

# moduleload pbind.la

# moduleload pcache.la

# moduleload ppolicy.la

# moduleload refint.la

# moduleload retcode.la

# moduleload rwm.la

# moduleload seqmod.la

# moduleload smbk5pwd.la

# moduleload sssvlv.la

# moduleload syncprov.la

# moduleload translucent.la

# moduleload unique.la

# moduleload valsort.la

# The next three lines allow use of TLS for encrypting connections using a

# dummy test certificate which you can generate by running

# /usr/libexec/openldap/generate-server-cert.sh. Your client software may balk

# at self-signed certificates, however.

TLSCACertificatePath /etc/openldap/certs

TLSCertificateFile "\"OpenLDAP Server\""

TLSCertificateKeyFile /etc/openldap/certs/password

# Sample security restrictions

# Require integrity protection (prevent hijacking)

# Require 112-bit (3DES or better) encryption for updates

# Require 63-bit encryption for simple bind

# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:

# Root DSE: allow anyone to read it

# Subschema (sub)entry DSE: allow anyone to read it

# Other DSEs:

#  Allow self write access

#  Allow authenticated users read access

#  Allow anonymous users to authenticate

# Directives needed to implement policy:

# access to dn.base="" by * read

# access to dn.base="cn=Subschema" by * read

# access to *

# by self write

# by users read

# by anonymous auth

#

# if no access controls are present, the default policy

# allows anyone and everyone to read anything but restricts

# updates to rootdn.  (e.g., "access to * by * read")

#

# rootdn can always read and write EVERYTHING!

# enable on-the-fly configuration (cn=config)

database config

access to *

by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage

by * none

# enable server status monitoring (cn=monitor)

database monitor

access to *

by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read

by dn.exact="cn=Directory Manager,o=h3gat" write

by * none

#######################################################################

# database definitions

#######################################################################

database sql

suffix  "o=h3gat"

rootdn  "cn=Directory Manager,o=h3gat"

rootpw  {SSHA}rJ3sVQ8nJ3Mp5an0UeSm2sTb4XWE3r6J

dbname          ldap

dbuser          linying

dbpasswd        123456

subtree_cond    "ldap_entries.dn LIKE CONCAT(‘%‘,?)"

insentry_stmt   "INSERT INTO ldap_entries(dn, oc_map_id, parent, keyval) VALUES(?, ?, ?, ?)"

has_ldapinfo_dn_ru no

# The database directory MUST exist prior to running slapd AND

# should only be accessible by the slapd and slap tools.

# Mode 700 recommended.

#directory /var/lib/ldap

# Indices to maintain for this database

#index objectClass                       eq,pres

#index ou,cn,mail,surname,givenname      eq,pres,sub

#index uidNumber,gidNumber,loginShell    eq,pres

#index uid,memberUid                     eq,pres,sub

#index nisMapName,nisMapEntry            eq,pres,sub

# Replicas of this database

#replogfile /var/lib/ldap/openldap-master-replog

#replica host=ldap-1.example.com:389 starttls=critical

#     bindmethod=sasl saslmech=GSSAPI

#     authcId=host/[email protected]

4. 删除默认配置文件,赋权,重新生成新配置文件

rm -rf /etc/openldap/slapd.d/*

chown -R ldap:ldap /var/lib/ldap/

chown -R ldap:ldap /etc/openldap/

slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d/

5. 赋权,启动openldap

chown -R ldap.ldap /etc/openldap/slapd.d/*

service slapd start

6. 停止openldap,查看mysql连接

service slapd stop

slapd -d 1

注:安装中请注意版本,尽量与我版本一致,rpm包在文件栏中。

时间: 2024-10-02 09:40:32

ldap连接mysql (openldap-2.4.40 rpm + 操作系统CentOS 6.5标准版)的相关文章

MySQLdb库连接MySQL数据库

Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具.Cacti是通过 snmpget来获取数据,使用 RRDtool绘画图形,而且你完全可以不需要了解RRDtool复杂的参数.它提供了非常强大的数据和用户管理功能,可以指定每一个用户能查看树状结构.host以及任何一张图,还可以与LDAP结合进行用户验证,同时也能自己增加模板,功能非常强大完善.界面友好.软件 Cacti 的发展是基于让 RRDTool 使用者更方便使用该软件,除了基本的 Snmp 流量

通过java连接mysql总结

简介:通过java连接mysql需要用到JDBC驱动.JDBC驱动安装在mysql-client客户端,mysql-server服务端不需要安装. 数据库安装初始化略.测试用到的命令: 1.创建测试用库,表,字段: create database score; use score; create table score(id nvarchar(10),stu_id nvarchar(10),c_name nvarchar(10),grade nvarchar(10)); insert into

MVC3、如何应用EntityFramework 连接MySql 数据库

原文:MVC3.如何应用EntityFramework 连接MySql 数据库 新的一年,新的开始. 今天总结的主题是在MySql中应用EntityFramework 的Code First模式. 开发环境:Win8 + MySql5.5 +VS 2012. 第一步是在数据库中新建一个表,具体字段如下图. 在表中添加若干数据: 数据建好之后,下面就是在项目中引用EntityFramework了. 二,在项目中新建一个实体类Product public class Product    {    

13.1 设置更改root密码;13.2 连接MySQL;13.3 MySQL常用命令

扩展 : mysql5.7 root密码更改 http://www.apelearn.com/bbs/thread-7289-1-1.html myisam 和innodb引擎对比 http://www.pureweber.com/article/myisam-vs-innodb/ mysql 配置详解: http://blog.linuxeye.com/379.html mysql调优: http://www.aminglinux.com/bbs/thread-5758-1-1.html 同学

Java连接MySQL数据库——含步骤和代码

工具:eclipse MySQL5.6 MySQL连接驱动:mysql-connector-java-5.1.27.jar 加载驱动: 1. 在工程目录中创建lib文件夹,将下载好的JDBC放到该文件夹下,如下图所示: 2. 右键工程名,在java build path中的Libraries分页中选择Add JARs...,选择刚才添加的JDBC,如下图: 数据包准备: 在数据库sqltestdb中创建如下数据表emp: CREATE TABLE emp( empno INT(4) PRIMAR

java jdbc 连接mysql数据库 实现增删改查

好久没有写博文了,写个简单的东西热热身,分享给大家. jdbc相信大家都不陌生,只要是个搞java的,最初接触j2ee的时候都是要学习这么个东西的,谁叫程序得和数据库打交道呢!而jdbc就是和数据库打交道非常基础的一个知识,也是比较接近底层的,在实际的工作中大家用得更多的其实还是比较成熟的框架,例如Hibernate.Mybatis. 但是作为这些成熟框架的底层的jdbc却也是我们应该去掌握的,只有了解了jdbc的增删改查,这样在以后如果有兴趣去研究Hibernate或者Mybatis的源代码的

2-23-实现jsp通过tomcat连接mysql

什么是Tomcat 官方网站:http://tomcat.apache.org/ Tomcat 是 Apache 软件基金会(Apache Software Foundation)的 Jakarta 项目中的一个核心项目,由 Apache.Sun 和其他一些公司及个人共同开发而成.由于有了 Sun 的参与和支持,最新的 Servlet 和JSP 规范总是能在 Tomcat 中得到体现,Tomcat 5 支持最新的 Servlet 2.4 和 JSP 2.0 规范.因为Tomcat 技术先进.性能

连接mysql出错

mysql version: 5.5.40 mysql community server 不论是从图形界面软件还是java通过jdbc连接,始终提示出错: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. at sun.reflect.GeneratedConstructorAccessor

c# 连接Mysql数据库

mysql.data.dll下载_c#连接mysql必要插件 全部版本下载:http://hovertree.com/h/bjaf/0sft36s9.htm mysql.data.dll是C#操作MYSQL的驱动文件,是c#连接mysql必要插件,使c#语言更简洁的操作mysql数据库.当你的电脑弹出提示“丢失mysql.data.dll”或“无法找到mysql.data.dll”等错误问题,请下载本站为你提供的dll文件,使用它可以帮助用户解决上述问题.dll文件修复方法:1.解压下载的文件.