def save(self): success = super(LDAPUser, self).save() if success == False: return success # If I just set the password... # TODO: make this detect password changes, rather than just being not none if self.password is not None: logger.debug("Setting password for %s" % self.username) if not self.password: logger.info('Password set to empty value; randomly generating password and expiring password') # For deactivated accounts. Possibly also for setting the password and emailing it to people. self.password = utils.randstring(10) self.setstate('expire-password', True) # run(['passwd', self.username], '%s\n%s\n' % (self.password, self.password)) self.con.passwd_s(self.id, None, self.password) self.reload(attr='shadowLastChange') if self.state('expire-password'): self.do_expire_password() elif self.state('unexpire-password'): self.do_unexpire_password() return True
def set_random_password(self): self.setstate('set_random_password', True) self.password_confirmation = self.password = utils.randstring(6) return self.password