Skip to content

Instantly share code, notes, and snippets.

$ yum install -y openldap-servers openldap-clients authconfig
$ mv /etc/openldap/slapd.d /etc/openldap/slapd.d.bckp
@kamituel
kamituel / gist:4528783
Created January 14, 2013 09:14
/etc/openldap/slapd.conf
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
database bdb
suffix "dc=example,dc=com"
$ touch /var/lib/ldap/DB_CONFIG
$ service slapd start
$ chkconfig slapd on
$ service ldap stop
$ chown -R ldap /var/lib/ldap
$ rm -f /var/lib/ldap/alock
$ db_recover
$ service ldap start
@kamituel
kamituel / gist:4528835
Created January 14, 2013 09:22
Populating LDAP schemas
$ cat > base.ldif <<EOM
dn: dc=example,dc=com
dc: example
objectClass: top
objectClass: domain
dn: ou=People,dc=example,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit
@kamituel
kamituel / gist:4528840
Created January 14, 2013 09:23
Add users group to LDAP
$ cat > group.ldif <<EOM
dn: cn=john,ou=Group,dc=example,dc=com
cn: john
userPassword: {crypt}x
gidNumber: 2001
objectClass: posixGroup
objectClass: top
EOM
$ ldapmodify -a -h localhost \
@kamituel
kamituel / gist:4528843
Last active December 11, 2015 02:09
Add user to LDAP
$ cat > john.txt <<EOM
dn: uid=john,ou=People,dc=example,dc=com
userPassword: johnpass
cn: john
uid: john
givenName: John The User
sn: 1
shadowLastChange: 12345
shadowMax: 99999
shadowWarning: 7
@kamituel
kamituel / gist:4528849
Last active December 11, 2015 02:09
Dumping all info from LDAP.
$ ldapsearch -h localhost \
-D "cn=Manager,dc=example,dc=com" \
-w secret \
-s sub
"objectclass=*"
@kamituel
kamituel / gist:4528862
Last active December 11, 2015 02:09
Using authconfig to enable LDAP login.
$ authconfig --enableldap \
--enableldapauth \
--ldapserver=127.0.0.1 \
--ldapbasedn="dc=example,dc=com" \
--disableldaptls \
--update