* Fixed some bugs related to meta groups

* Fixed a typo on WinDomainOsManager
* Fixed a typo on Authenticator creation by xmlrpc
This commit is contained in:
Adolfo Gómez 2013-03-12 00:12:12 +00:00
parent de9124707e
commit 70cb226c8c
7 changed files with 26 additions and 19 deletions

View File

@ -93,11 +93,11 @@ class GroupsManager(object):
lst += (g['group'].dbGroup().id,)
yield g['group']
# Now, get metagroups and also return them
for g in dbGroup.objects.filter(manager__id=self._dbAuthenticator.id, is_meta=False):
for g in dbGroup.objects.filter(manager__id=self._dbAuthenticator.id, is_meta=True):
gn = g.groups.filter(id__in=lst, state=State.ACTIVE).count()
if gn == g.groups.count(): # If a meta group is empty, all users belongs to it. we can use gn != 0 to check that if it is empty, is not valid
# This group matches
yield g
yield Group(g)
def hasValidGroups(self):

View File

@ -74,13 +74,14 @@ class User(object):
if self._groups == None:
if self._manager.isExternalSource == True:
self._manager.getGroups(self._dbUser.name, self._groupsManager())
self._groups = self._groupsManager().getValidGroups()
self._groups = list(self._groupsManager().getValidGroups())
logger.debug(self._groups)
# This is just for updating "cached" data of this user, we only get real groups at login and at modify user operation
usr = DbUser.objects.get(pk=self._dbUser.id)
lst = ()
for g in self._groups:
if g.dbGroup().is_meta == False:
lst += (g.id,)
lst += (g.dbGroup().id,)
usr.groups = lst
else:
# From db

View File

@ -777,9 +777,8 @@ class UserInterface(object):
# Set all values to defaults ones
for k in self._gui.iterkeys():
if self._gui[k].isType(gui.InputField.HIDDEN_TYPE) and self._gui[k].isSerializable() is False:
logger.debug('Field {0} is not unserializable'.format(k))
#logger.debug('Field {0} is not unserializable'.format(k))
continue
self._gui[k].value = self._gui[k].defValue
for txt in values.decode('zip').split('\002'):
@ -793,7 +792,7 @@ class UserInterface(object):
except:
val = ''
self._gui[k].value = val
logger.debug('Value for {0}:{1}'.format(k, val))
#logger.debug('Value for {0}:{1}'.format(k, val))
@classmethod
def guiDescription(cls, obj = None):

View File

@ -99,9 +99,11 @@ class WinDomainOsManager(WindowsOsManager):
l.protocol_version = ldap.VERSION3
account = self._account
if account.find('@') is False:
if account.find('@') == -1:
account += '@' + self._domain
logger.debug('Account data: {0}, {1}, {2}, {3}'.format(self._account, self._domain, account, self._password))
l.simple_bind_s(who = account, cred = self._password)
return l
@ -123,6 +125,7 @@ class WinDomainOsManager(WindowsOsManager):
logger.warn('Could not find _ldap._tcp.'+self._domain)
log.doLog(service, log.WARN, "Could not remove machine from domain (_ldap._tcp.{0} not found)".format(self._domain), log.OSMANAGER);
except ldap.LDAPError as e:
logger.exception('Ldap Exception caught')
log.doLog(service, log.WARN, "Could not remove machine from domain (invalid credentials for {0})".format(self._account), log.OSMANAGER);
#_filter = '(&(objectClass=computer)(sAMAccountName=%s$))' % service.friendly_name

View File

@ -152,7 +152,7 @@ def index(request):
java = request.session['java']
# We look for services for this authenticator groups. User is logged in in just 1 authenticator, so his groups must coincide with those assigned to ds
groups = request.user.getGroups()
groups = list(request.user.getGroups())
availServices = DeployedService.getDeployedServicesForGroups(groups)
availUserServices = UserService.getUserAssignedServices(request.user)

View File

@ -152,7 +152,7 @@ def createAuthenticator(credentials, type, data):
auth = None
try:
auth = Authenticator.objects.create(name = dict_['name'], comments = dict_['comments'],
data_type = type, priority=int(dict_['priority'], small_name=dict_['smallName']))
data_type = type, priority=int(dict_['priority']), small_name=dict_['smallName'])
auth.data = auth.getInstance(dict_).serialize()
auth.save()
except auths.Authenticator.ValidationException as e:

View File

@ -34,7 +34,7 @@
from django.db import IntegrityError
from uds.models import User as DbUser, Group as DbGroup, Authenticator as DbAuthenticator, State
from uds.core.managers.CryptoManager import CryptoManager
from ..util.Exceptions import DuplicateEntryException, InsertException
from ..util.Exceptions import DuplicateEntryException, InsertException, ParametersException
from uds.core.auths.Exceptions import AuthenticatorException, InvalidUserException
from AdminAuth import needs_credentials
from Groups import dictFromGroup
@ -72,13 +72,17 @@ def getUsers(credentials, idParent):
def getUser(credentials, id):
'''
'''
usr = User(DbUser.objects.get(pk=id))
grps = []
for g in usr.groups():
grps.append(dictFromGroup(g.dbGroup()))
logger.debug(grps)
return dictFromUser(usr.dbUser(), grps)
try:
usr = User(DbUser.objects.get(pk=id))
grps = []
for g in usr.groups():
logger.debug(g)
grps.append(dictFromGroup(g.dbGroup()))
logger.debug(grps)
return dictFromUser(usr.dbUser(), grps)
except Exception as e:
logger.exception('Unhandled exception')
raise ParametersException(str(e))
@needs_credentials
def createUser(credentials, usr):