반응형
OpenLDAP 스크립트로 그룹 생성 및 사용자 계정
그룹 아이디 생성
$ cat ldapGroupAddv3.sh
#!/bin/bash
# GroupName, GidNumber
echo "dn: cn=$1,ou=Groups,dc=4wxyz,dc=com
changetype: add
objectClass: top
objectClass: posixGroup
#objectClass: groupOfUniqueNames
gidNumber: $2
cn: $1
#uniqueMember: <DN of member>
#memberUid: 1501
description: groups" > .tmp/$1-group.ldif
#DATA Insert
docker exec openldap ldapmodify -a -x \
-D cn=admin,dc=4wxyz,dc=com \
-H ldap://127.0.0.1 \
-w ldappassword \
-f /container/service/slapd/assets/custome/.tmp/$1-group.ldif
#DATE Search
echo "DATE Search :"
docker exec openldap ldapsearch -x -b dc=4wxyz,dc=com -D "cn=admin,dc=4wxyz,dc=com" \
-w ldappassword -LLL -Z dn | egrep $1
그룹 이름: apart, GID : 2110
$ ./ldapGroupAddv3.sh apart 2100
--output--
adding new entry "cn=apart,ou=Groups,dc=4wxyz,dc=com"
DATE Search :
dn: cn=apart,ou=Groups,dc=4wxyz,dc=com
사용자 계정 생성
#!/bin/bash
# FirstName, UserName, UIDNumber, E-Mail
echo "dn: uid=$2,ou=People,dc=4wxyz,dc=com
uid: $2
cn: $1
sn: $1
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetorgperson
objectClass: posixAccount
givenName: $1
mail: $4@4wxyz.com
gecos: $1
loginShell: /bin/bash
uidNumber: $3
gidNumber: $3
homeDirectory: /home/$2
userPassword: {SSHA}UZrWRlhxpXK+aAfPGz5B+wloR+Iaw9TV
description: User Create" > .tmp/$2-user.ldif
#DATA Insert
docker exec openldap ldapmodify -a -x \
-D cn=admin,dc=4wxyz,dc=com \
-H ldap://127.0.0.1 \
-w ldappassword \
-f /container/service/slapd/assets/custome/.tmp/$2-user.ldif
#DATE Search
echo "DATE Search :"
docker exec openldap ldapsearch -x -b dc=4wxyz,dc=com -D "cn=admin,dc=4wxyz,dc=com" \
-w ldappassword -LLL -Z dn | egrep $2
사용자 이름: sangchul, 아이디: scbyun, UID: 2101, 이메일: scbyun
$ ./ldapUserAddv3.sh sangchul scbyun 2101 scbyun
--output--
adding new entry "uid=scbyun,ou=People,dc=4wxyz,dc=com"
DATE Search :
dn: uid=scbyun,ou=People,dc=4wxyz,dc=com
728x90
반응형
'리눅스' 카테고리의 다른 글
[LDAP] phpLDAPadmin 설치 및 연동 (0) | 2021.06.14 |
---|---|
[LDAP] OpenLDAP 클라이언트 설치 (0) | 2021.06.13 |
[LDAP] OpenLDAP Password Policy overlay (ppolicy) (0) | 2021.06.13 |
[LDAP] OpenLDAP 그룹 및 계정 생성 (0) | 2021.06.13 |
[LDAP] OpenLDAP 설치 및 구성 (0) | 2021.06.11 |