前回の続きです。
LDAP→ODBC反映とは
LDAPフィルタの条件に合致したユーザをODBCデータソースを介してDBに反映するプラグインです。
事前準備
MySQLの準備
LDAP Managerのサポートリストより、MySQL 8.4を反映先DBとしました。
RHEL 9.4のリポにはMySQL 8.4がないので、リポを追加します。
$ dnf install https://dev.mysql.com/get/mysql84-community-release-el9-1.noarch.rpm
追加後、インストールを実施します。
$ dnf install mysql-server
MySQLサービスを開始します。
$ systemctl start mysqld
MySQLのroot
ユーザの初期パスワードを確認します。
$ cat /var/log/mysqld.log
2024-12-18T08:29:50.980903Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2024-12-18T08:29:50.982771Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.4.3) initializing of server in progress as process 29048
2024-12-18T08:29:51.035404Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-12-18T08:29:55.098009Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-12-18T08:29:59.226056Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: yTBFuj=3737*
2024-12-18T08:30:03.192714Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.
2024-12-18T08:30:03.265782Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2024-12-18T08:30:03.526420Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.4.3) starting as process 29086
2024-12-18T08:30:03.566004Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2024-12-18T08:30:05.431772Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2024-12-18T08:30:06.184268Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2024-12-18T08:30:06.184352Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2024-12-18T08:30:06.302704Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2024-12-18T08:30:06.303189Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.4.3' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
yTBFuj=3737*
が初期パスワードのようです。
MySQLの初期設定を行います。
以下のコマンドを実行します。
$ mysql_secure_installation
mysql_secure_installation
最初にroot
ユーザのパスワードを聞かれるので、先ほど確認した初期パスワードを入力します。
Securing the MySQL server deployment.
Enter password for user root:
次に、再設定するroot
ユーザのパスワードを入力します。
The existing password for the user account root has expired. Please set a new password.
New password:
Re-enter new password:
先ほどパスワード検証コンポーネントの検証に耐えるパスワードをroot
ユーザに設定したのでここはN
とします。
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N
... skipping.
匿名ユーザを削除します。
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
リモートからのroot
ユーザでの接続は不許可とします。
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
test
データベースは削除します。
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
資格情報テーブルをリロードします。
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
MySQLがリッスンするアドレスとポートを/etc/my.cnf
に指定してMySQLを再起動します。
+ port=3306
+ bind-address = 0.0.0.0
$ systemctl restart mysqld
ユーザ、データベース、テーブルを作成します。
$ mysql -p
Enter password:
mysql> create user 'odbcuser'@'%' IDENTIFIED BY 'P@sw0rd+';
Query OK, 0 rows affected (0.02 sec)
mysql> create database lmodbc;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on lmodbc.* to odbcuser;
Query OK, 0 rows affected (0.00 sec)
mysql> create table lmodbc.ldapuser (
-> employeenumber varchar(10) PRIMARY KEY,
-> passwordexpirationtime time,
-> passwordexpirationdate date,
-> commonname varchar(15),
-> surname varchar(15),
-> givenname varchar(15),
-> userid varchar(44),
-> ldapm varchar(2)
-> );
Query OK, 0 rows affected (0.04 sec)
ODBCデータソースの準備
提供サイトからインストーラーをダウンロードし、LDAP Managerがインストールされているサーバにインストールします。
インストール後、ODBC データ ソース アドミニストレーター(64ビット)より、ODBCドライバのセットアップを行います。
Unicode版のODBCドライバを使用します。
MySQL上に設定したユーザとデータベースを設定し、接続を確認して保存します。
プラグインの設定
LDAP Manager コンソールから「環境設定」 > 「LDAP -> ODBC反映1」を選択します。
まず、抽出元LDAPサーバとデータソース情報を設定します。
次に、テーブル情報の「追加」を押下し、反映先テーブルに関する設定を行います。
LDAPサーバからの抽出フィルタと、対象テーブル名を指定します。
その後、ODBC属性名の「属性インポート」を押下し、テーブルの列情報を読み込みます。
取得した列情報からレコード識別属性を指定します。(必要な場合)
マッピングは以下のように行いました。
確認
プラグインを手動実行します。
レコードがDBに挿入されます。
mysql> select * from lmodbc.ldapuser;
+----------------+------------------------+------------------------+------------+----------+-----------+----------------------------------------------+-------+
| employeenumber | passwordexpirationtime | passwordexpirationdate | commonname | surname | givenname | userid | ldapm |
+----------------+------------------------+------------------------+------------+----------+-----------+----------------------------------------------+-------+
| 1 | 09:58:33 | 3024-04-21 | user1 | Tanaka | Jiro | Q5LRABncLhvWgoOQteHF9ib6iyDRQFUBWwUklrCoK3o= | LM |
| 2 | 09:58:49 | 3024-04-21 | user2 | Nakamura | Tomoki | YvVzDsmeC70Ai+eHp6e3tLfEXdX5+1qVlk4xBqqKudc= | LM |
| 3 | 09:59:02 | 3024-04-21 | user3 | Koga | Yujiro | QJvfnol2ktrLqwTMWeQJ2P5LU8o9JB6YssMOrdierU8= | LM |
+----------------+------------------------+------------------------+------------+----------+-----------+----------------------------------------------+-------+
3 rows in set (0.00 sec)
この通り、変更情報や削除が反映されています。
mysql> select * from lmodbc.ldapuser;
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
| employeenumber | passwordexpirationtime | passwordexpirationdate | commonname | surname | givenname | userid | ldapm |
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
| 1 | 09:58:33 | 3024-04-21 | user1 | Tanaka | Jiro | Q5LRABncLhvWgoOQteHF9ib6iyDRQFUBWwUklrCoK3o= | LM |
| 2 | 10:16:45 | 3024-04-21 | user2 | Yasuda | Tomoki | YvVzDsmeC70Ai+eHp6e3tLfEXdX5+1qVlk4xBqqKudc= | LM |
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
2 rows in set (0.00 sec)
レコード識別属性について確認します。
以下のように、レコード識別属性ldapm
に指定の属性値LM
が含まれないようにします。
mysql> update lmodbc.ldapuser SET ldapm = 'NO' where employeenumber = '2';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select * from lmodbc.ldapuser;
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
| employeenumber | passwordexpirationtime | passwordexpirationdate | commonname | surname | givenname | userid | ldapm |
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
| 1 | 18:58:33 | 3024-04-21 | user1 | Tanaka | Jiro | F8vW6uFbjqtWuLgrGD1uASrfJPPl9zVOP/W5UhiqfJQ= | LM |
| 2 | 19:16:45 | 3024-04-21 | user2 | Yasuda | Tomoki | HfBnEJiOitSW9g9ik5YdN5nMWeCPnGuR+MJrOhxev6o= | NO |
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
2 rows in set (0.00 sec)
ユーザ情報を変更します。
ここでLDAP→ODBC反映を実行すると、更新処理がスキップされます。
mysql> select * from lmodbc.ldapuser;
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
| employeenumber | passwordexpirationtime | passwordexpirationdate | commonname | surname | givenname | userid | ldapm |
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
| 1 | 18:58:33 | 3024-04-21 | user1 | Tanaka | Jiro | F8vW6uFbjqtWuLgrGD1uASrfJPPl9zVOP/W5UhiqfJQ= | LM |
| 2 | 19:16:45 | 3024-04-21 | user2 | Yasuda | Tomoki | HfBnEJiOitSW9g9ik5YdN5nMWeCPnGuR+MJrOhxev6o= | NO |
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
2 rows in set (0.00 sec)
最後に、抽出フィルタを変更します。
このようにフィルタに合致しなくなったユーザが削除されます。
mysql> select * from lmodbc.ldapuser;
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
| employeenumber | passwordexpirationtime | passwordexpirationdate | commonname | surname | givenname | userid | ldapm |
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
| 1 | 09:58:33 | 3024-04-21 | user1 | Tanaka | Jiro | Q5LRABncLhvWgoOQteHF9ib6iyDRQFUBWwUklrCoK3o= | LM |
+----------------+------------------------+------------------------+------------+---------+-----------+----------------------------------------------+-------+
1 row in set (0.01 sec)
ODBC → LDAP反映とは
データベースからODBCを介してユーザ情報をLDAPサーバに連携するプラグインです。
事前準備
SQL Server Expressの準備
抽出元DBにはSQL Server 2022 Expressを使用します。
提供サイトからインストーラーをダウンロードして実行します。
SSMSもインストールしています。
SQL Server構成マネージャー > SQL Server ネットワークの構成 > SQLEXPRESSのプロトコル > TCP/IPを「有効」とします。
IPAll
のTCPポートを指定します。
データベースの準備
SSMSを起動してSQL Serverに接続します。
SQL Server認証モードを有効にします。
新しいデータベースを作成します。
UTF-8に対応させるため照合順序を変更します。
ログインを作成します。
「既定のデータベース」をodbclm
にします。
次に、データベースユーザを作成します。
データベースユーザとログインをマッピングし、既定のスキーマを設定します。
今回は既定のdbo
を使用するので他にスキーマは設定しません。
メンバーシップ(ロール)はdb_owner
を割り当ててしまいます。
セキュリティ保護は特にしないので設定しません。
これで、ログインodbclm
でSQL Serverに接続できます。
最後にテーブルを作成します。プラグインの設定でRDN属性
とする属性とマッピングされる列を必ず作成する必要があります。
create table employees (
employeenumber varchar(10) PRIMARY KEY,
surname varchar(50),
givenname varchar(50)
);
ODBCデータソースの準備
提供サイトからインストーラーをダウンロード、インストールします。
ODBC データ ソース アドミニストレーター(64 ビット)より、SQL Server用のデータソースを追加します。
プラグインの設定
プラグインをインストールします。
LDAP Managerコンソール「環境設定」 > 「ODBC -> LDAP反映1」を開きます。
まず「基本設定」を行います。
ODBC、LDAPの情報を設定します。抽出条件用SQLにはselect * from employees
を指定しました。
次に、「ODBC属性名設定」から「属性インポート」します。
「マッピング設定」は以下のようにしました。先述の通り、RDN属性(ここではcn
)にマッピングするODBC属性(列)が存在する必要があります。
確認
現在、データベースにはレコードがなく、LDAPサーバには2つのユーザエントリが存在する状態です。
この状態で実行すると、LDAPサーバ側のユーザエントリは削除(無効化)されます。
データベースにデータを挿入してからプラグインを実行します。
データがLDAPに反映されます。
DB側のデータを更新して再度プラグインを実行します。
update employees
SET surname = 'Watanabe'
where employeenumber = '4'
;
LDAP側の更新が確認できます。
抽出条件を変更します。
'4'
というemployeenumber
を持つユーザが抽出されなくなり、以下の通り無効化処理が実施されます。
まとめ
LDAPから/LDAPへDBの情報を連携する2つのプラグインについての検証でした。
次の記事では、LDAP Managerのワークフローシステムである IDワークフロー について検証します。