示例#1
0
    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()
示例#2
0
 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))
示例#3
0
    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()
示例#4
0
    def testKnownValues(self):
        """nthash(...) gives known results"""
        for password, expected in self.knownValues:

            result = smbpassword.nthash(password)

            self.assertEqual(expected, result)
示例#5
0
    def testKnownValues(self):
        """nthash(...) gives known results"""
        for password, expected in self.knownValues:

            result = smbpassword.nthash(password)

            self.assertEqual(expected, result)
示例#6
0
 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])
示例#8
0
 def testKnownValues(self):
     """nthash(...) gives known results"""
     self.assertEqual(
         self.knownValues,
         [(p, smbpassword.nthash(p)) for p, _ in self.knownValues]
     )