The LDAP "sambaNTPassword" attribute is really just an MD4 hash of the UTF-16LE encoded password. Using bash(1) with iconv(1) and openssl(1), it may be generated like so: (read -s pw; printf '%s' "$pw" |iconv -futf8 -tutf-16le |openssl md4 -hex |tr a-z A-Z) Using perl(1) it looks like this: use Digest::MD4 'md4_hex'; use Encode 'encode'; sub nthash { uc md4_hex encode('UTF-16LE', shift) } Don't ever do this, it's insecure as fuck: https://en.wikipedia.org/wiki/MD4#Security