Python/Samba

Aus Shea Wiki
Version vom 1. Januar 1970, 01:00 Uhr von Suelmann (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Encoding sambaNTPassword With Python

Samba's sambaNTPassword attribute, which mimics the corresponding NT / Active Directory attribute, has a value that must be a hex encoded MD4 hash of the user's password with a UTF-16 encoding. Fortunately generating such a string is a Python one-liner.


import hashlib

password = 'fred123'
nt_password = hashlib.new('md4', password.encode('utf-16le')).digest().encode('hex').upper()


Note that Samba wants all the alpha characters in the string as upper-case. The result will always be 32 characters long.


KategorieWissen