Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create users in command line? #227

Closed
pedrofurtado opened this issue Jun 20, 2018 · 4 comments
Closed

How to create users in command line? #227

pedrofurtado opened this issue Jun 20, 2018 · 4 comments
Labels

Comments

@pedrofurtado
Copy link

How do I create an LDAP user, in command line, with docker command?

@bazy1983
Copy link

first off you need to get into the container
docker exec -it bash
generate new password if you want to add a user
slappasswd -h {} then hit enter
it will ask you to enter new password and confirm it
once you get your password, copy it so that you can use it when you create a user record
then you do
ldapadd -x -D "cn=admin,dc=,dc= -W
then it will ask for admin password, once you enter that, it will wait for you to enter new record like so
dn: ou=groups,dc=,dc=
objectclass: organizationalUnit
objectclass: top
ou: users
then hit enter twice to push your entry
for users it will go exactly the some way except you need to add more infomation
dn: uid=,ou=,dc=,dc=
cn: first name lastname
givenname: first name
sn: last name
uid: username
uidnumber:
userpassword:
gid: this is important to add of you are creating posixAccount
homedirectory: /home/users/
loginshell: /bin/sh
objectclass: inetOrgPerson
objectclass: posixAccount
objectclass: top

PS: you probably need to lay your user DN like so "uid,ou,dc,dc" especially if you are using ldap for user login and authentication

@lhty24
Copy link

lhty24 commented Sep 16, 2019

Hi, I did the command below but didn't get prompt for admin password.
ldapadd -x -D "cn=admin,dc=,dc= -W
Could you pls advise? thanks

@pedrofurtado
Copy link
Author

pedrofurtado commented Sep 16, 2019

Hey @lhty24 @BertrandGouny ! We here create following these steps:

Example:

mkdir my-folder
cd my-folder

cat >> user.ldif <<EOL
dn: uid=admin,dc=example,dc=org
uid: admin
cn: admin
sn: 3
objectClass: top
objectClass: posixAccount
objectClass: inetOrgPerson
loginShell: /bin/bash
homeDirectory: /home/admin
uidNumber: 14583102
gidNumber: 14564100
userPassword: admin
mail: admin@example.com
gecos: admin
EOL

docker container run --name my_ldap_server -v $(pwd):/container/service/slapd/assets/test -p 3089:389 -d osixia/openldap

docker container exec my_ldap_server ldapadd -D "cn=admin,dc=example,dc=org" -w admin -f /container/service/slapd/assets/test/user.ldif

@pedrofurtado
Copy link
Author

I will close the issue because for me it was resolved. But let me know @lhty24 if your doubt was satisfied. If not, we can reopen the issue later 👍 🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants