Skip to content

Instantly share code, notes, and snippets.

@dbazile
Last active May 13, 2021 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbazile/896023917f3fcdf5843da86e06458c75 to your computer and use it in GitHub Desktop.
Save dbazile/896023917f3fcdf5843da86e06458c75 to your computer and use it in GitHub Desktop.
create account via LDAP in FreeIPA and Active Directory
#
# FreeIPA
#
ldapmodify \
-h 'ipa.test.priv' \
-x \
-D "$BIND_DN" \
-w "$BIND_PW" \
"$@" \
<<-EOT
dn: uid=test,cn=users,cn=accounts,dc=test,dc=priv
changetype: add
objectclass: top
objectclass: person
# vvvvvvvvvvvv-------- without this, the user won't show up in FreeIPA's UI
objectclass: posixaccount
objectclass: inetuser
objectclass: inetorgperson
objectclass: ipaobject
cn: Test User
uid: test
sn: User
givenname: Test
userPassword: test
# the following attrs belong to posixaccount:
homeDirectory: /tmp
gidNumber: 9999999
uidNumber: 9999999
EOT
#
# Active Directory
#
ldapmodify \
-x \
-H 'ldaps://dc.test.priv' \
-D "$BIND_DN" \
-w "$BIND_PW" \
"$@" \
<<-EOT
dn: cn=test, ou=domain users, dc=test, dc=priv
changetype: add
objectclass: top
objectclass: person
objectclass: user
cn: test
givenname: test
userAccountControl: $(( 0x00000200 | 0x00010000 ))
unicodePwd:: $( printf '"password"' | iconv -t UTF16LE | base64 )
EOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment