既にLDAPサーバ構築にてトップドメインの定義が終わって、ユーザとグループの枠が既にある。

ここではこの枠にデータを流し込む

まずはグループから登録する

過去記事LDAP/データ登録181006

グループ登録

ここではxrayem、そしてadminグループを登録してみます。

下記のようなLDIFファイル(group.ldif)を作ります。
複数のデータを登録するには空行を挟みます。

[root@ldap-server ~]# vi ldap/group.ldif
dn: cn=xray,ou=group,dc=sybyl,dc=local
objectClass: posixGroup
cn: xray
gidNumber: 2001
 
dn: cn=em,ou=group,dc=sybyl,dc=local
objectClass: posixGroup
cn: em
gidNumber: 2002
 
dn: cn=admin,ou=group,dc=sybyl,dc=local
objectClass: posixGroup
cn: admin
gidNumber: 2003
[root@ldap-server ~]#

これをldapaddコマンドで登録します

[root@ldap-server ~]# ldapadd -x -D cn=Manager,dc=sybyl,dc=local -W -f ldap/group.ldif
Enter LDAP Password:
adding new entry "cn=xray,ou=group,dc=sybyl,dc=local"
 
adding new entry "cn=em,ou=group,dc=sybyl,dc=local"
 
adding new entry "cn=admin,ou=group,dc=sybyl,dc=local"
 
[root@ldap-server ~]#

一方で下記のようなエラーが発生する場合がある

[root@ldap-server ~]# ldapadd -x -D cn=Manager,dc=sybyl,dc=local -W -f ldap/group.ldif
Enter LDAP Password:
ldapadd: attributeDescription "dn": (possible missing newline after line 10, entry "cn=xray,ou=group,dc=sybyl,dc=local"?)
ldapadd: attributeDescription "dn": (possible missing newline after line 11, entry "cn=xray,ou=group,dc=sybyl,dc=local"?)
adding new entry "cn=xray,ou=group,dc=sybyl,dc=local"
ldap_add: Type or value exists (20)
        additional info: objectClass: value #0 provided more than once
 
[root@ldap-server ~]#

この際は、入力に使ったファイルを調べます。大抵は上記をコピペした場合は空行にスペースがあるためにエラーとなります。

[root@ldap-server ~]# od -c ldap/group.ldif
  :
0000100   n   :       x   r   a   y  \n   g   i   d   N   u   m   b   e    -->「n: xray\ngidNumbe」
0000120   r   :       2   0   0   1  \n      \n   d   n   :       c   n    -->「r: 2001\n \ndn: cn」 <-- \nと\nの間に隙間がある. これを削除します
0000140   =   e   m   ,   o   u   =   g   r   o   u   p   ,   d   c   =
  : 
[root@ldap-server ~]#

空行のスペースを削除しして再度インポートを行います

LDAP Adminから参照すると下記のようになる。
2018y10m06d_232249370.png

ユーザ登録

グループが出来たので、次はユーザです。
ユーザ登録用のLDIFファイル(foo.ldif)を用意します。

一つのLDIFファイルに複数のユーザ情報を記載しても構わないのですが、一人1枚で作ってみます。

記載内容ですが、「ou=People」に対してはユーザfooの追加(add)行為で、
ou=Group」に対してはグループxrayへの修正(modify)行為となる事に注意

*userPasswordの値はslappasswdコマンドで作成

[root@ldap-server ~]# cat ldap/foo.ldif
dn: uid=foo,ou=people,dc=sybyl,dc=local
changetype: add
objectClass: person
objectClass: posixAccount
objectClass: inetOrgPerson
objectClass: shadowAccount
uid: foo
cn: foo sybyl
sn: foo
givenName: sybyl
mail: foo@sybyl.local
uidNumber: 3000
gidNumber: 2001
homeDirectory: /home/foo
userPassword: {SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
loginShell: /bin/bash
shadowLastChange: 10000
shadowMin: 0
shadowMax: 99999
shadowWarning: 14
shadowInactive: 99999
shadowExpire: -1
 
dn: cn=xray,ou=Group,dc=sybyl,dc=local
changetype: modify
add: memberUid
memberUid: foo
[root@ldap-server ~]#

そして同様にldapaddコマンドでデータを登録します

[root@ldap-server ~]# ldapadd -x -D cn=Manager,dc=sybyl,dc=local -W -f ldap/foo.ldif
Enter LDAP Password:
adding new entry "uid=foo,ou=people,dc=sybyl,dc=local"
 
modifying entry "cn=xray,ou=Group,dc=sybyl,dc=local"
 
[root@ldap-server ~]#

LDAP Adminから「ou=People」確認すると
2018y10m06d_233924242.png
となる。
また「ou=Group」では「cn=xray」に登録されている
2018y10m06d_234023532.png

最新の60件
2025-02-17 2025-02-15 2025-02-14 2025-02-12 2025-02-03 2025-02-02 2025-02-01 2025-01-27 2025-01-26 2025-01-25 2025-01-24 2025-01-23 2025-01-20 2025-01-13 2025-01-12 2025-01-08 2024-12-30 2024-12-29 2024-12-22 2024-12-20 2024-12-17 2024-12-15 2024-12-14 2024-12-12 2024-12-11 2024-12-10 2024-12-09 2024-12-08 2024-11-28 2024-11-22 2024-11-15 2024-11-14 2024-11-12 2024-11-06 2024-11-05 2024-11-04 2024-11-02 2024-11-01 2024-10-28 2024-10-27 2024-10-23 2024-10-18 2024-10-17 2024-10-15 2024-10-14

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2022-11-12 (土) 17:10:23