Last active
May 13, 2021 16:34
-
-
Save dbazile/896023917f3fcdf5843da86e06458c75 to your computer and use it in GitHub Desktop.
create account via LDAP in FreeIPA and Active Directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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