15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【LDAP環境構築:3】 グループLDIF作成から登録まで

Posted at
LDAP サーバーへのデータの登録

######グループ追加用LDIF作成スクリプトを用意する

touch /etc/openldap/tmp/create_group_ldif.sh
chmod 700 /etc/openldap/tmp/create_group_ldif.sh
vi /etc/openldap/tmp/create_group_ldif.sh
create_group_ldif.sh
#!/bin/sh
>
read -p "ベースDN(例:dc=example,dc=com) : " BASE_DN_NAME
read -p "グループ名(例:testgroup)       : " GROUP_NAME
read -p "グループID(例:1001)            : " GROUP_ID
>
echo "
dn: cn=${GROUP_NAME},ou=Group,${BASE_DN_NAME}
objectClass: posixGroup
objectClass: top
cn: ${GROUP_NAME}
gidNumber: ${GROUP_ID}
"
グループ追加用LDIFファイル作成
/etc/openldap/tmp/create_group_ldif.sh > /etc/openldap/tmp/group.ldif
ベースDN(例:dc=example,dc=com) : dc=example,dc=com
グループ名(例:testgroup)       : testgroup
グループID(例:1001)            : 9999
グループ追加LDIFファイルを登録
ldapadd -x -D "cn=Manager,dc=example,dc=com" -W -f /etc/openldap/tmp/group.ldif
    adding new entry "cn=testgroup,ou=Group,dc=example,dc=com"
確認
ldapsearch  -x -b 'dc=example,dc=com' 'cn=testgroup'
# extended LDIF
#
# LDAPv3
# base <dc=example,dc=com> with scope subtree
# filter: cn=testgroup
# requesting: ALL
#
# testgroup, Group, example.com
dn: cn=testgroup,ou=Group,dc=example,dc=com
objectClass: posixGroup
objectClass: top
cn: testgroup
gidNumber: 9999
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
後片付け
rm /etc/openldap/tmp/group.ldif
15
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?