def setPassword_Samba(self, newPasswd, style=None): """ Set the Samba password on this object. @param newPasswd: A string containing the new password. @param style: one of 'sambaSamAccount', 'sambaAccount' or None. Specifies the style of samba accounts used. None is default and is the same as 'sambaSamAccount'. @return: A Deferred that will complete when the operation is done. """ self._checkState() nthash = smbpassword.nthash(newPasswd) lmhash = smbpassword.lmhash(newPasswd) if style is None: style = 'sambaSamAccount' if style == 'sambaSamAccount': self['sambaNTPassword'] = [nthash] self['sambaLMPassword'] = [lmhash] elif style == 'sambaAccount': self['ntPassword'] = [nthash] self['lmPassword'] = [lmhash] else: raise RuntimeError("Unknown samba password style %r" % style) return self.commit()
def testKnownValues(self): """nthash(...) gives known results""" for password, expected_result in self.knownValues: result = smbpassword.nthash(password) if result != expected_result: raise AssertionError, 'nthash(%s)=%s, expected %s' \ % (repr(password), repr(result), repr(expected_result))
def setPassword_Samba(self, newPasswd, style=None): """ Set the Samba password on this object. @param newPasswd: A string containing the new password. @param style: one of 'sambaSamAccount', 'sambaAccount' or None. Specifies the style of samba accounts used. None is default and is the same as 'sambaSamAccount'. @return: A Deferred that will complete when the operation is done. """ self._checkState() nthash=smbpassword.nthash(newPasswd) lmhash=smbpassword.lmhash(newPasswd) if style is None: style = 'sambaSamAccount' if style == 'sambaSamAccount': self['sambaNTPassword'] = [nthash] self['sambaLMPassword'] = [lmhash] elif style == 'sambaAccount': self['ntPassword'] = [nthash] self['lmPassword'] = [lmhash] else: raise RuntimeError, "Unknown samba password style %r" % style return self.commit()
def testKnownValues(self): """nthash(...) gives known results""" for password, expected in self.knownValues: result = smbpassword.nthash(password) self.assertEqual(expected, result)
def testKnownValues(self): """nthash(...) gives known results""" for password, expected_result in self.knownValues: result = smbpassword.nthash(password) if result != expected_result: raise AssertionError, "nthash(%s)=%s, expected %s" % ( repr(password), repr(result), repr(expected_result), )
def testKnownValues(self): """nthash(...) gives known results""" self.assertEqual(self.knownValues, [(p, smbpassword.nthash(p)) for p, _ in self.knownValues])
def testKnownValues(self): """nthash(...) gives known results""" self.assertEqual( self.knownValues, [(p, smbpassword.nthash(p)) for p, _ in self.knownValues] )