弄了大半天了,總算把LDAP搞出來了
話說因為耍笨找錯講義,下午兩個鐘頭做了白工
直覺不對要找人問問,感謝沈老大提醒^____^
接著就很高興的做到托育班快放學就又卡關了
回家不信邪的從頭做,終於確認是phpldapadmin管理者密碼結尾不能有空白(又是兩個鐘頭飛走T___T)。
弄到剛剛,連上FG110C後,用route print確認成功,瞬間高興起來
整理一下指令給下一任參考參考
資料來源:臺中市105年度中小學學務系統升級暨資安建置研習手冊(沈俊達)
在CentOS7上安裝OpenLDAP Server
yum -y install openldap-servers openldap-clients
rm -rvf /etc/openldap/slapd.d
mkdir /etc/openldap/slapd.d
cp /usr/share/openldap-servers/slapd.ldif /etc/openldap/slapd.conf
cd /etc/openldap
slappasswd > password.txt
tail password.txt
(把內容複製到記事本備用)
vi /etc/openldap/slapd.conf
把所有的dc=my-domain,dc=com改成dc=tjes,dc=tc,dc=edu,dc=tw
然後結尾補上
olcRootPW: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxx
(從剛剛記事本那邊貼過來)
/usr/libexec/openldap/convert-config.sh
head -20 /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{[12]*
slaptest -u
config file testing succeeded
rm -rvf /var/lib/ldap/*
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
rm -rvf certs
mkdir certs
/usr/libexec/openldap/create-certdb.sh
Creating certificate database in '/etc/openldap/certs'.
/usr/libexec/openldap/generate-server-cert.sh
Creating new server certificate in '/etc/openldap/certs'.
chown ldap:ldap -R /var/lib/ldap/
systemctl start slapd
slaptest
config file testing succeeded
systemctl enable slapd
firewall-cmd --permanent --zone=public --add-port=389/tcp
firewall-cmd --reload
ldapwhoami -WD cn=Manager,dc=tjes,dc=tc,dc=edu,dc=tw
Enter LDAP Password:
dn:cn=Manager,dc=tc,dc=edu,dc=tw
dn:cn=Manager,dc=tc,dc=edu,dc=tw
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f
/etc/openldap/schema/inetorgperson.ldif
vi domain.ldif
dn: dc=tjes,dc=tc,dc=edu,dc=tw
objectClass: dcObject
objectclass: organization
dc: tjes
objectClass: dcObject
objectclass: organization
dc: tjes
o: tjes
dn: ou=teacher,dc=tjes,dc=tc,dc=edu,dc=tw
objectClass: organizationalUnit
ou: teacher
description: teachers account
objectClass: organizationalUnit
ou: teacher
description: teachers account
dn: ou=student,dc=tjes,dc=tc,dc=edu,dc=tw
objectClass: organizationalUnit
ou: student
description: students account
objectClass: organizationalUnit
ou: student
description: students account
(注意上面的句子一定要分成三段,從講義直接貼出來沒有分段會有錯誤)
ldapadd -D cn=Manager,dc=clpes,dc=tc,dc=edu,dc=tw -W -f domain.ldif
Enter LDAP Password:
adding new entry "dc=tjes,dc=tc,dc=edu,dc=tw"
adding new entry "ou=teacher,dc=tjes,dc=tc,dc=edu,dc=tw"
adding new entry "ou=student,dc=tjes,dc=tc,dc=edu,dc=tw"
adding new entry "dc=tjes,dc=tc,dc=edu,dc=tw"
adding new entry "ou=teacher,dc=tjes,dc=tc,dc=edu,dc=tw"
adding new entry "ou=student,dc=tjes,dc=tc,dc=edu,dc=tw"
yum install phpldapadmin
vi /etc/phpldapadmin/config.php
:set number
(顯示行號)
(找到397行改下面這樣)
$servers->setValue('login','attr','dn');
// $servers->setValue('login','attr','uid');
// $servers->setValue('login','attr','uid');
vi /etc/httpd/conf.d/phpldapadmin.conf
<Directory /usr/share/phpldapadmin/htdocs>
<IfModule mod_authz_core.c>
# Apache 2.4
Require local
Require ip 163.17.233.0/24
<IfModule mod_authz_core.c>
# Apache 2.4
Require local
Require ip 163.17.233.0/24
(在Require local之後加入上面這行,這是限制只有指定的ip可以存取phpldapadmin
(突然覺得phpmysqladmin也該這樣)
(突然覺得phpmysqladmin也該這樣)
systemctl start httpd
systemctl enable httpd
firewall-cmd --permanent --zone=public --add-port=80/tcp
vi /etc/httpd/conf.d/phpldapadmin.conf
登入 http://ldap-server-ip/phpldapadmin
帳號: cn=Manager,dc=tjes,dc=tc,dc=edu,dc=tw
(登入如出現密碼錯誤,請確認是否密碼句尾有空白字元,是的話要可能得從前面步驟再來一次)
到這邊ldap server部分就ok了
再來要看郭老大這篇,新增三個模組到學務系統
cd /var/www/html/sfs3/modules/
wget
http://www.wpjh.tc.edu.tw/joomla/attachments/article/367/stu_ldap_pass.zip
wget
http://www.wpjh.tc.edu.tw/joomla/attachments/article/367/manage_ldap.zip
wget
http://www.wpjh.tc.edu.tw/joomla/attachments/article/367/ch_ldap_pass.zip
unzip stu_ldap_pass.zip
unzip manage_ldap.zip
unzip ch_ldap_pass.zip
chown apache.apache stu_ldap_pass -R
chown apache.apache manage_ldap -R
chown apache.apache ch_ldap_pass -R
然後去學務系統新增這三個模組,
去模組權限管理的預設值設定參數
(ip可以設定127.0.0.1)
把自己的帳號啟用
最後參考這篇去改FG110C就可以了(得先照講義把SSLVPN設定到本機帳號可以登入,再看這篇去新增LDAP群組)
您好,我是hanson.有參考您的範例嘗試建立LDAP server,在執行ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif指令時出現以下錯誤,不知道是否有機會打擾你請教這個錯誤問題,謝謝.
回覆刪除[root@localhost openldap]# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/cosine.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
adding new entry "cn=cosine,cn=schema,cn=config"
ldap_add: Other (e.g., implementation specific) error (80)
這我也不清楚,我也是看講義照著做的
回覆刪除可以從錯誤代碼下去找找看
https://www.ptt.cc/bbs/Linux/M.1448023565.A.2B0.html
謝謝~
回覆刪除