Mysql+ODBC+OpenLDAP

# 1、安装相关软件
yum install wget unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel -y
yum install mysql-connector-odbc autoconf automake cmake freetype-devel gcc gcc-c++ git libtool make groff -y

yum -y install mysql-server
service mysqld start
chkconfig mysqld on

mysql_secure_installation

mysql -uroot -pdsideal
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
CREATE USER 'ldap'@'%' IDENTIFIED BY 'ldap';
GRANT ALL PRIVILEGES ON ldap.* TO 'ldap'@'%';
CREATE USER 'ldap'@'localhost' IDENTIFIED BY 'ldap';
GRANT ALL PRIVILEGES ON ldap.* TO 'ldap'@'localhost';
FLUSH PRIVILEGES;
show databases;


# 2、开始配置ODBC
vi /etc/odbcinst.ini
#=======================================================
# Example driver definitions

# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/lib/psqlodbc.so
Setup           = /usr/lib/libodbcpsqlS.so
Driver64        = /usr/lib64/psqlodbc.so
Setup64         = /usr/lib64/libodbcpsqlS.so
FileUsage       = 1


# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib64/libmyodbc5.so
Setup = /usr/lib64/libodbcmyS.so
FileUsage = 1
#====================================================
vi /etc/odbc.ini

[mysql]
Description           = MySQL connection to 'asterisk' database
Driver                = MySQL
Database              = openldap
Server                = 127.0.0.1
UserName              = root
Password              = dsideal
Port                  = 3306
Socket                = /var/lib/mysql/mysql.sock
charset               = UTF8
option                = 3
#======================================
# 测试UnixODBC的安装正确性
echo "select 1" | isql -v mysql
#======================================
# 3、安装OpenLDAP
cd /opt
wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-release/openldap-2.4.45.tgz
tar xvfz openldap-2.4.45.tgz
rm -rf openldap-2.4.45.tgz
mv openldap-2.4.45 openldap
cd /opt/openldap
./configure --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/share/man --infodir=/usr/share/info --enable-sql --disable-bdb --disable-ndb --disable-hdb
make depend
make && make install

此时安装已经完成,接着配置LDAP,首先生成自己的LDAP密码:

slappasswd

我获取了:{SSHA}j5cp4ebCG79mcx/5jdM6dL+XtJ0ztlKs

vi /etc/openldap/slapd.conf

#在第5行下面添加如下内容
include         /etc/openldap/schema/cosine.schema
include         /etc/openldap/schema/inetorgperson.schema

#修改第55行内容
database sql
#修改第56、57行的dc值(这里最好设置为example,因为后面要用ldap的数据库数据,如果这里使用别的值,那么对应的要把数据库中的所有dn都改掉)
suffix "dc=example,dc=com"
rootdn "cn=Manager,dc=example,dc=com"

#修改第61行rootpw的值,就是之前获取到的加密密码
rootpw {SSHA}j5cp4ebCG79mcx/5jdM6dL+XtJ0ztlKs

#注释掉第65、67行的内容
#directory /var/openldap-data
#index objectClass eq
#在第61行rootpw下面添加如下内容
rootpw {SSHA}XDEtT6s3MTzrSbHeJl7OlRoqk0w1By1X
dbname ldap
dbuser ldap
dbpasswd ldap
has_ldapinfo_dn_ru no
subtree_cond "ldap_entries.dn LIKE CONCAT('%',?)"


mysql -uldap -pldap
CREATE DATABASE IF NOT EXISTS ldap;
use ldap;
source /opt/openldap/servers/slapd/back-sql/rdbms_depend/mysql/backsql_create.sql
source /opt/openldap/servers/slapd/back-sql/rdbms_depend/mysql/testdb_create.sql
source /opt/openldap/servers/slapd/back-sql/rdbms_depend/mysql/testdb_data.sql
source /opt/openldap/servers/slapd/back-sql/rdbms_depend/mysql/testdb_metadata.sql

此时运行LDAP
/opt/openldap/servers/slapd/slapd -d 5 -h 'ldap:/// ldapi:///' -f /etc/openldap/slapd.conf &




posted @ 2017-11-22 13:58  糖豆爸爸  阅读(896)  评论(0编辑  收藏  举报
Live2D