企業人員的統一管理-FreeIPA學習筆記

從FreeIPA的首頁來看,她想要解決識別、方針(Policy)管理與微軟的AD相互信任的目標。
識別其實是為了能夠做到單一簽入(SSO,Single Sing On),從另一個角度來看就是人員的統一管理,實際上很難,在Web不盛行的時代,還可透過Kerberos(解說)來做到Desktop Single Sing On或LDAP(UNIX BASE)做到統一帳號管理,從而達成所有主機人員權限的統一管理,但Web就不容易了,因為瀏覽器沒有規定一定要支援Kerberos(Firefox除外,Firefox可支援Kerberos存取FreeIPA的WebUI),所以要在瀏覽器做到SSO,大概的方式不是透過SAML就是透過OpenID, 好在FreeIPA支援SAML(透過IPSILON)與OpenID(因為我用的開發工具是JAVA,所以開發過OPENID的範例,不要與OAuth搞混了,SSO是從上而下的管理管理眾人,而OAuth是由客戶決定其它站台是否可以存取我的個人資料,是由下而上的管理)。
方針(Policy)管理則是限制用戶什麼可以做,什麼不可以做。主要控制的是Linux系統,像SUDO、Autofs等;至於對Window與AD的整合,老實說因為我不懂AD,所以不知道FreeIPA在這方面可以做什麼?
所以對我來說,FreeIPA至少是一個提供企業一個統合管理人員識別的好地方(企業內的人員因為多系統而儲存於不同的資料庫,在管理上其實是不太方便)。
FreeIPA同微軟的AD一樣,都是目錄服務提供者,說穿了,目錄服務就是扮演了資料庫的角色,只不過這個資料庫可以在不同機器間複製罷了。FreeIPA跟AD一樣,可以設定管理DNS,我的建議是一定要裝,做為企業內部的DNS,便於內部系統程式使用名稱取代IP。不過需要注意的是:FreeIPA經安裝後會mask掉原本的named service,改用她所提供的named-pkcs11 service,不過她也說了bla,bla...,不要用ACL與VIEW。
IPA的術語有三個:
Server:FreeIPA的管控主機,第一個建立的也稱master(可建立別台主機為replica)
Replica:也是FreeIPA的管控主機,從另一臺master Server同步(拷貝)資料過來,當然Replica也可以是Master
Cleient:受管控的機器,其執行方針受制於 IPAServer
以下的說明將涵蓋Server、Replica與Client的建置與Trouble Shooting,

主機安裝

以下的實做練習需要準備兩台VM(兩臺都要有實體IP),這裡用VirtualBOX(橋接介面卡)、CentOS7,建立至少兩台平等的Server,以建立High Availability(我覺得這是最好的方案)(以下所有黑底黃字為console手打輸入)。
先準備第一台,安裝好並更新後執行
#現在是ipa1主機
$echo ipa1.example.com.tw > /etc/hostname && hostnamectl --static set-hostname ipa1.example.com.tw
$yum -y install ipa-server ipa-server-dns bind bind-dyndb-ldap
#因為這時還無DNS,最好讓兩台主機彼此知道IP,所以/etc/hosts要有以下兩行
$grep ipa /etc/hosts
192.168.10.ipa1位址 ipa1.example.com.tw ipa1
192.168.10.ipa2位址 ipa2.example.com.tw ipa2
#因為是VM的關係,請到這裡下載haveged-x.x.x-x.el7.x86_64.rpm並安裝
$rpm -ivh haveged-x.x.x-x.el7.x86_64.rpm
#設置防火牆
$firewall-cmd --permanent --zone=public --add-service=freeipa-ldap
$firewall-cmd --permanent --zone=public --add-service=freeipa-ldaps
$firewall-cmd --permanent --zone=public --add-service=ntp
$firewall-cmd --permanent --zone=public --add-service=dns
$firewall-cmd --permanent --zone=public --add-service=freeipa-replication
$service firewalld reload
ipa1關機並備分硬碟名稱為 ip1-preared
注意:若不想開放Port 389,請把上述的防火牆設定的第一行改成如下以限定成特定IP才可進入(不可關閉389否則主機間無法複製)
$firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.10.0/24" service name="freeipa-ldap" accept'
$service firewalld reload

準備第二台,安裝好並更新後執行
#現在是ipa2主機
$echo ipa1.example.com.tw > /etc/hostname && hostnamectl --static set-hostname ipa2.example.com.tw
$yum -y install ipa-server ipa-server-dns bind bind-dyndb-ldap
#因為這時還無DNS,最好讓兩台主機彼此知道IP,所以/etc/hosts要有以下兩行
$grep ipa /etc/hosts
192.168.10.ipa2位址 ipa1.example.com.tw ipa1
192.168.10.ipa2位址 ipa2.example.com.tw ipa2
#因為是VM的關係,請到這裡下載haveged-x.x.x-x.el7.x86_64.rpm並安裝
$rpm -ivh haveged-x.x.x-x.el7.x86_64.rpm
#設置防火牆
$firewall-cmd --permanent --zone=public --add-service=freeipa-ldap
$firewall-cmd --permanent --zone=public --add-service=freeipa-ldaps
$firewall-cmd --permanent --zone=public --add-service=ntp
$firewall-cmd --permanent --zone=public --add-service=dns
$firewall-cmd --permanent --zone=public --add-service=freeipa-replication
$service firewalld reload
ipa2關機並備分硬碟名稱為 ip2-preared
ipa1開機進行第1台IPA主機安裝
#現在是ipa1主機
$ipa-server-install --setup-dns
This program will set up the IPA Server.

Server host name [ipa.example.com.tw]:
Please confirm the domain name [example.com.tw]:
Please provide a realm name [EXAMPLE.COM.TW]:
Directory Manager password:輸入目錄管理員的密碼
Password (confirm):再輸入一次目錄管理員密碼確認
IPA admin password:輸入IPA管理員(admin)的密碼
Password (confirm):再輸入一次IPA管理員密碼確認
Existing BIND configuration detected, overwrite? [no]: yes
Do you want to configure DNS forwarders? [yes]:
#這裡使用google與中華電的dns做forwarder
Enter an IP address for a DNS forwarder, or press Enter to skip: 8.8.8.8
DNS forwarder 8.8.8.8 added. You may add another.
Enter an IP address for a DNS forwarder, or press Enter to skip: 168.95.192.1
DNS forwarder 8.8.4.4 added. You may add another.
Enter an IP address for a DNS forwarder, or press Enter to skip:
Checking DNS forwarders, please wait …
Do you want to configure the reverse zone? [yes]:
Please specify the reverse zone name [10.168.192.in-addr.arpa.]:
Using reverse zone(s) 10.168.192.in-addr.arpa.
...(輸出省略)
Continue to configure the system with these values? [no]:yes
...(輸出省略)
下一步:
    1. 您必須確保以下網路埠有打開:
       TCP Ports:
         * 80, 443: HTTP/HTTPS
         * 389, 636: LDAP/LDAPS
         * 88, 464: kerberos
         * 53: bind
       UDP Ports:
         * 88, 464: kerberos
         * 53: bind
         * 123: ntp

    2. 您可以以右列命令取得kerberos tick: 'kinit admin'
      This ticket will allow you to use the IPA tools (e.g., ipa user-add)
      and the web user interface.

記得備份存放在/root/cacert.p12的憑證檔,在建立replica時會用到,其密碼為目錄管理員的密碼
#輯輯/etc/ntp.conf,變更ntp server 為臺灣主機
$grep -e ^server /etc/ntp.conf
server tock.stdtime.gov.tw iburst
server watch.stdtime.gov.tw iburst
server time.stdtime.gov.tw iburst
server clock.stdtime.gov.tw iburst
server tick.stdtime.gov.tw iburst
$service ntpd restart
這樣ipa1就設置完成,請用瀏覽器開啟 https://ipa1.example.com.tw/ipa/ui/ 並使用admin/IPA管理員密碼 進入管理。

另外我們應該禁止LDAP Server Annonymous Bind,請執行以下指令
$ldapmodify -x -D 'cn=Directory Manager' -W
Enter LDAP Password:輸入目錄管理員的密碼
dn: cn=config
changetype: modify
replace: nsslapd-allow-anonymous-access
nsslapd-allow-anonymous-access: rootdse
^D(按CTRL+D結束)
modifying entry "cn=config"
#重啟目錄服務
$restart-dirsrv


Master安裝失敗

若是過程式失敗,請執行以下清除動作後再重新安裝。
#現在是ipa1主機
#清除安裝
$ipa-server-install --uninstall
#檢查是否有監控中的認證服務
$ipa-getcert list
Number of certificates and requests being tracked: 7.
Request ID '20160815065400':
   status: MONITORING
   stuck: no
...(輸出省略)
#若有以上輸出再執行, 紅色號碼為上述輸出之監視編號
$ipa-getcert stop-tracking -i 20160815065400
完成後再重新安裝。

Replica安裝

然後我們準備對ipa2設定replica,首先我們在ipa1下進行以下指令
#現在是ipa1主機
#設定replica必須暫時開放下列port
$firewall-cmd --zone=public --add-port=9443/tcp
$firewall-cmd --zone=public --add-port=9444/tcp
$firewall-cmd --zone=public --add-port=9445/tcp
$service firewalld reload
#以下指令建立replica 檔案,
$ipa-replica-prepare ipa2.example.com.tw
Directory Manager (existing master) password:輸入目錄管理員的密碼

Preparing replica for ipa2.example.com.tw from ipa.example.com.tw
...(輸出省略)
Waiting for ipa2.example.com.tw. A or AAAA record to be resolvable
This can be safely interrupted (Ctrl+C)
^CInterrupted
The ipa-replica-prepare command was successful
然後把ipa1下的/var/lib/ipa/replica-info-ipa2.example.com.tw.gpg 拷貝到ipa2機的目錄下,後進入ipa2機,進行replica設置
#現在是ipa2主機
#設定replica必須暫時開放下列port
$firewall-cmd --zone=public --add-port=8443/tcp
$firewall-cmd --zone=public --add-port=9443/tcp
$firewall-cmd --zone=public --add-port=9444/tcp
$firewall-cmd --zone=public --add-port=9445/tcp
$service firewalld reload
#以下指定進行安裝replica
#  --setup-ca 讓本replica變成master,可再由此建立新的replica
#  --setup-dns與--forward為設定dns服務,若不指定,仍然可管理DNS,
#              因為DNS的資料在Ldap資料庫內,但實際上不會有DNS服務
$ipa-replica-install --setup-ca --skip-conncheck --setup-dns --forward 8.8.8.8 --forward 168.95.192.1 replica-info-ipa2.example.com.tw.gpg
Directory Manager (existing master) password:輸入目錄管理員的密碼

ipa         : ERROR    Could not resolve hostname ipa2.example.com.tw using DNS. Clients may not function properly. Please check your DNS setup. (Note that this check queries IPA DNS directly and ignores /etc/hosts.)
Continue? [no]: yes
Existing BIND configuration detected, overwrite? [no]: yes
Checking DNS forwarders, please wait …
...(輸出省略)
Restarting the web server
#安裝完成,若要強迫同步master的資料,請執行
$ipa-replica-manage force-sync --from ipa.example.com.tw
Directory Manager password:輸入目錄管理員的密碼
...
完成後,現在ipa2因為--setup-ca參數,現在ipa2也可以作為master建立其它replica。

Crash復原

假設ipa1此時因為硬體問題而掛點了,先把之前備分的ip1-preared硬碟拷貝蓋掉現在的ipa硬碟,然後從ipa2開始進行回復。
#現在是ipa2主機
#中斷複製關聯
$ipa-replica-manage del ipa1.example.com.tw --force
#以下指令建立replica 檔案,
$ipa-replica-prepare ipa1.example.com.tw
Directory Manager (existing master) password:輸入目錄管理員的密碼
...(輸出省略)
Packaging replica information into /var/lib/ipa/replica-info-ipa1.example.com.tw.gpg
The ipa-replica-prepare command was successful
把產生的replica-info-ipa1.example.com.tw.gpg拷貝到ipa1後
#現在是ipa1主機
#設定replica必須暫時開放下列port
$firewall-cmd --zone=public --add-port=8443/tcp
$firewall-cmd --zone=public --add-port=9443/tcp
$firewall-cmd --zone=public --add-port=9444/tcp
$firewall-cmd --zone=public --add-port=9445/tcp
$service firewalld reload

$ipa-replica-install --setup-ca --skip-conncheck --setup-dns --forward 8.8.8.8 --forward 168.95.192.1 replica-info-ipa1.example.com.tw.gpg
Directory Manager (existing master) password:輸入目錄管理員的密碼
Existing BIND configuration detected, overwrite? [no]: yes
Checking DNS forwarders, please wait …
...(輸出省略)
Restarting the web server
現在若是ipa2掛了,比照辦理從ipa1復原就可以了

用戶與群組編號

註:IPA使用各種plugin來建立各種功能, 其中有一個DNA plugin負責分配用戶與群組的uid與gid,若無可用編號時將無法建立user或group,我們先查詢ipa1的分配狀況(參考官方文件)
#現在是ipa1主機
$ldapsearch -x -D 'cn=Directory Manager' -W -b 'cn=Posix IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config' dnaMaxValue dnaNextValue
$ipa-replica-manage dnarange-show
Enter LDAP Password:輸入目錄管理員的密碼
...(輸出省略)
dnaMaxValue: 1552399999
dnaNextValue: 1552200000
ipa1.example.com.tw: 94000002-94199999
ipa2.example.com.tw: No range set
...(輸出省略)
然後再看看ipa2的分配狀況
#現在是ipa2主機
$ldapsearch -x -D 'cn=Directory Manager' -W -b 'cn=Posix IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config' dnaMaxValue dnaNextValue
Enter LDAP Password:輸入目錄管理員的密碼
...(輸出省略)
dnaMaxValue: 1100
dnaNextValue: 1101
...(輸出省略)
ipa2 dna的下個編號居然大於最大允許編號沒有可分配範圍,我們試著關閉ipa1的IPA服務
#現在是ipa1主機
$ipactl stop
然後在ipa2增加用戶
#現在是ipa2主機
$kinit admin
Password for admin@EXAMPLE.COM.TW:輸入目錄管理員的密碼
$ipa user-add kent --first=Kent --last=Yeh
ipa: ERROR: Operations error: Allocation of a new value for range cn=posix ids,cn=distributed numeric assignment plugin,cn=plugins,cn=config failed! Unable to proceed.
得到錯誤,果然不允許新增用戶,我們把ipa1的IPA服務重新上起來
#現在是ipa1主機
$ipactl start
然後在ipa2增加用戶,並檢查DNS plugin的分配狀況
#現在是ipa2主機
$ipa user-add kent --first=Kent --last=Yeh
Added user "kent"
-----------------
 User login: kent
 First name: Kent
 Last name: Yeh
...(輸出省略)
$ldapsearch -x -D 'cn=Directory Manager' -W -b 'cn=Posix IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config' dnaMaxValue dnaNextValue
ipa-replica-manage dnarange-show ipa2.example.com.tw
Enter LDAP Password:輸入目錄管理員的密碼
...(輸出省略)
dnaMaxValue: 1552399999
dnaNextValue: 1552300501
...(輸出省略)
ipa2.example.com.tw: 1552300501-1552399999
重新關閉ipa1的IPA服務,然後再ipa2新增用戶,此時可以發現ipa2得到了分配號碼的權利,也就是每一臺主機的分配範圍要彼此錯開。
假設從來沒有在ipa2建立過用戶,而ipa1又掛了,那麼該怎麼辦?很簡單,重新設定ipa2的dnaMaxValue與dnaNextValue就可以了,首先:找出目前那些號碼被用掉了
#現在是ipa2主機
$ldapsearch -x -D 'cn=Directory Manager' -W -b 'cn=accounts,dc=example,dc=com,dc=tw' -s sub '(|(uidNumber=*)(gidNumber=*))' uidNumber gidNumber
Enter LDAP Password:輸入目錄管理員的密碼
...(輸出省略)
# admin, users, accounts, example.com.tw
dn: uid=admin,cn=users,cn=accounts,dc=example,dc=com,dc=tw
uidNumber: 1552200000
gidNumber: 1552200000
# admins, groups, accounts, example.com.tw
dn: cn=admins,cn=groups,cn=accounts,dc=example,dc=com,dc=tw
gidNumber: 1552200000

# editors, groups, accounts, example.com.tw
dn: cn=editors,cn=groups,cn=accounts,dc=example,dc=com,dc=tw
gidNumber: 1552200002

# kent, users, accounts, example.com.tw
dn: uid=kent,cn=users,cn=accounts,dc=example,dc=com,dc=tw
uidNumber: 1552300500
gidNumber: 1552300500
...(輸出省略)
result: 0 Success
然後我們把 1552400500 ~ 1552400499 (避開已用過的號碼)分配給ipa2
注意:linux編號數字可使用的範圍,不要指定超出範圍的數字
#現在是ipa2主機
$ldapmodify -x -D 'cn=Directory Manager' -W
Enter LDAP Password:輸入目錄管理員的密碼
dn: cn=Posix IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config
changetype: modify
replace: dnaNextValue
dnaNextValue: 1552400500
-
replace: dnaMaxValue
dnaMaxValue: 1552400599
^D(按CTRL+D結束)
modifying entry "cn=Posix IDs,cn=Distributed Numeric Assignment Plugin,cn=plugins,cn=config"
$ipa-replica-manage dnanextrange-set ipa2.example.com.tw 1552400500-1552400599
Enter LDAP Password:輸入目錄管理員的密碼

New range overlaps the DNA range on ipa2.example.com.tw
然後ipa2從此就可以新增用戶了

Replica安裝失敗

  1. 請先檢查防火牆8443、9443、9444、9445是否有正常開啟,上述firewalld-cmd指令只是暫時開放,防帶牆重啟或重開機就會消失,須重下指令開啟,若真不行,先停防火牆,裝好再重上。
  2. 檢查master與replica的/etc/hosts是否有指定彼此的ip位址
  3. 移除replica安裝
#現在是ipa2主機
$ipa-server-install --uninstall
This is a NON REVERSIBLE operation and will delete all data and configuration!

Are you sure you want to continue with the uninstall procedure? [no]: yes

WARNING: Failed to connect to Directory Server to find information about
...(輸出省略)
Unconfiguring directory server
#停止目錄服務
$stop-dirsrv
No instances found in /etc/sysconfig #目錄服務未執行的話出現左側訊息
  1. 移除replica與master的關聯
#現在是ipa1主機
$ipa-replica-manage del ipa2.example.com.tw --force

Server/Replica單機備援模式

無論是Server或是Replica都可以進行單機備援,單機備援可分為完整備援與資料備援,完整備援會停止IPA服務,而資料備援可在線上進行,資料備援其實就是LDAP備援,所以可以線上執行,但與LDAP備援不同的是資料備援不備份log,還有一點,單機備援是以名稱為主,例如ipa1.example.com.tw備份的資料只能在ipa1.example.com.tw主機進行復原。
#完整備份
$ipa-backup
Preparing backup on ipax.example.com.tw
Stopping IPA services
Backing up ipaca in EXAMPLE-COM-TW to LDIF
Backing up userRoot in EXAMPLE-COM-TW to LDIF
Backing up EXAMPLE-COM-TW
Backing up files
Backed up to /var/lib/ipa/backup/ipax-full-2017-01-01-01-02-03
Starting IPA service
The ipa-backup command was successful
備份檔案置於 /var/lib/ipa/backup/目錄下,現在我們用備份還原
#備份檔若在/var/lib/ipa/backup目錄下,可省略目錄名稱
$ipa-restore ipax-full-2017-01-01--02-03
Directory Manager (existing master) password:輸入目錄管理員的密碼

Preparing restore from /var/lib/ipa/backup/ipa-full-2017-01-01-01-02-03 on ipax.example.com.tw
Performing FULL restore from FULL backup
Restoring data will overwrite existing live data. Continue to restore? [no]: yes
...(輸出省略)
The ipa-restore command was successful
另外我們再試一下線上資料備份
#若是不加--online選項,則會停止IPA服務後再備份資料,--data指示資料備份
$ipa-backup --data --online
Preparing backup on ipax.example.com.tw
...(輸出省略)
Backed up to /var/lib/ipa/backup/ipax-data-2017-01-01-04-05-06
The ipa-backup command was successful
然後再作一次線上資料還原
#若是不加--online選項,則會停止IPA服務後再還原資料
$ipa-restore --data --onlin ipax-data-2017-01-01-04-05-06
Directory Manager (existing master) password:輸入目錄管理員的密碼

Preparing restore from /var/lib/ipa/backup/ipax-data-2017-01-01-04-05-06 on ipa.example.com.tw
Performing DATA restore from DATA backup
Restoring data will overwrite existing live data. Continue to restore? [no]: yes
...(輸出省略)
The ipa-restore command was successful

LDAP資料庫唯讀

389目錄服務器有個屬性值可將LDAP資料庫設為唯讀以便將資料凍結,
$ldapmodify -x -D 'cn=Directory Manager' -W
Enter LDAP Password:輸入目錄管理員的密碼
dn: cn=userRoot,cn=ldbm database,cn=plugins,cn=config
changetype: modify
replace: nsslapd-readonly
nsslapd-readonly: on
^D(按CTRL+D結束)
modifying entry "cn=userRoot,cn=ldbm database,cn=plugins,cn=config"
經測試發現,這個值不會複製到其它主機,在凍結其間,我在其它主機新增用戶,然後回來將凍結主機改為(nsslapd-readonly: off)時,新增人員立刻被複製回來,所以真要凍結資料,請關閉所有其它主機,然後再進行資料凍結

Linux Client 安裝

freeIPA支援很多種distro,可以在很多不同的Linux找到合適的Client安裝,以下仍以CentOs7為例:
#現在是Client
#安裝所需套件
$yum -y install ipa-client
...(輸出省略)
#ipa-client-install說明
#   --hostname 指令本Client機器名稱
#   --ntp-server=指定ntp主機
#   --enable-dns-updates 自動在DNS更新本機的IP
#   --mkhomedir 第一次登錄本機的帳號自動建home目錄,在client是email主機的情況下特別有用
$ipa-client-install -p admin -w IPA管理員密碼 --hostname ipaclient.example.com.tw --ntp-server=tock.stdtime.gov.tw --ntp-server=watch.stdtime.gov.tw --ntp-server=time.stdtime.gov.tw --ntp-server=clock.stdtime.gov.tw --ntp-server=tick.stdtime.gov.tw --enable-dns-updates --mkhomedir
DNS discovery failed to determine your DNS domain
Provide the domain name of your IPA server (ex: example.com): example.com.tw
Provide your IPA server name (ex: ipa.example.com): ipax.example.com.tw
The failure to use DNS to find your IPA server indicates that your resolv.conf file is not properly configured.
Autodiscovery of servers for failover cannot work with this configuration.
If you proceed with the installation, services will be configured to always access the discovered server for all operations and will not fail over to other servers in case of failure.
Proceed with fixed values and no DNS discovery? [no]: yes
Client hostname: ipaclient.example.com.tw
Realm: EXAMPLE.COM.TW
DNS Domain: example.com.tw
IPA Server: ipa.example.com.tw
BaseDN: dc=example,dc=com,dc=tw

Continue to configure the system with these values? [no]: yes
...(輸出省略)
Client configuration complete.
若要取消Client的Domain註冊,請執行以下指令(完成後要重新開機):
$ipa-client-install --uninstall
...(輸出省略)
Do you want to reboot the machine? [no]: yes
(重開機)

成員屬性

首先用瀏覽器開啟 https://ipa1.example.com.tw/ipa/ui/, 進入管理後,因為一般習慣以cn進行搜尋,所以我們先把cn加入搜尋欄位ipa1.png
如果新增人員時需指定額外的Ldap class時,也在同頁下放加入,例如:
ipa1.png
完成後按上方的Save按鍵儲存,則下次新增的人員時就預設會有customPerson(乃自訂屬性,見下節)的欄位可用。

自訂屬性

一般來說,官方所提供的人員屬性可能會有不足處,這時候就必須自定Schema(語法說明),我們仿這裡的範例,把以下自定屬性加入目錄服務的自訂義Schema(在/etc/dirsrv/slapd-EXAMPLE-COM-TW/schema/99user.ldif )檔的最後面
#如果您的企業/單位沒有申請OID,請用2.25.自訂UUID. 作為ldif的OID,這裡有產生器的範例
attributeTypes: ( 2.25.28639311321113238241701611583088740684.14.2.2
 NAME 'favoriteColorName'
 EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
 X-ORIGIN 'Extending FreeIPA' )
objectclasses: ( 2.25.28639311321113238241701611583088740684.14.2.1
 NAME 'customPerson'
 SUP top
 AUXILIARY
 MAY ( favoriteColorName )
 X-ORIGIN 'Extending FreeIPA' )
然後重新啟動目錄服務
#重啟目錄服務
$restart-dirsrv
然後我們建立WebUI
#建立plugin目錄
$mkdir  -p /usr/share/ipa/ui/js/plugins/favoriteColorName
#編寫js code(檔名要與目錄名相同)
$vi /usr/share/ipa/ui/js/plugins/favoriteColorName/favoriteColorName.js
#js code內容
define(['freeipa/phases','freeipa/user'],
 function(phases, user_mod) {
   // helper function
   function get_item(array, attr, value) {
     for (var i=0,l=array.length; i<l; i++) {
       if (array[i][attr] === value) return array[i];
     }
     return null;
 }

 var color_plugin = {};

 color_plugin.add_favorite_color = function() {
   var facet = get_item(user_mod.entity_spec.facets, '$type', 'details');
   var section = get_item(facet.sections, 'name', 'identity');
   section.fields.push({
     name: 'favoritecolorname',
     label: '愛好顏色'
   });
   return true;
 };

 phases.on('customization', color_plugin.add_favorite_color);

 return color_plugin;
});
#vi存檔
:x
立馬新增一個人員後(要先登出再登入)
ipa2.png

LDAP工具

個人覺得Apache Directory Studio,是個不錯的選擇,簡介使用方式如下:
首先建立一個連線ads1.png
ads2.png
ads3.png
ipa3.png
ads5.png
連線

ipa4.png
是的,至此我們可以將FreeIPA視為一個LDAP的資料庫並這個資料庫的管理WEB界面,然後我們的程式就可以從這個資料庫讀取人員的資料(包括人員的屬性與權限,若我們的程式有個別的權限管理也只要在這程式的內部實作而已),從而達到企業的單一登錄。

留言

這個網誌中的熱門文章

證交所最佳五檔的程式解析

Postgresql HA