Example #1
0
 def validate(self, parameters):
     """This method checks the provided username for validity and fills
     in the DN if needed."""
     # check username for validity
     common.validate_name(parameters['username'])
     # look up user DN
     entry = passwd.uid2entry(self.conn, parameters['username'])
     if not entry:
         # FIXME: we should close the stream with an empty response here
         raise ValueError('%r: user not found' % parameters['username'])
     # save the DN
     parameters['userdn'] = entry[0]
     # get the "real" username
     value = passwd.attmap.get_rdn_value(entry[0], 'uid')
     if not value:
         # get the username from the uid attribute
         values = entry[1]['uid']
         if not values or not values[0]:
             logging.warning('%s: is missing a %s attribute', entry[0], passwd.attmap['uid'])
         value = values[0]
     # check the username
     if value and not common.is_valid_name(value):
         raise ValueError('%s: has invalid %s attribute', entry[0], passwd.attmap['uid'])
     # check if the username is different and update it if needed
     if value != parameters['username']:
         logging.info('username changed from %r to %r', parameters['username'], value)
         parameters['username'] = value
Example #2
0
 def validate(self, parameters):
     """Check the username for validity and fill in the DN if needed."""
     # check username for validity
     common.validate_name(parameters['username'])
     # look up user DN
     entry = passwd.uid2entry(self.conn, parameters['username'])
     if not entry:
         # FIXME: we should close the stream with an empty response here
         raise ValueError('%r: user not found' % parameters['username'])
     # save the DN
     parameters['userdn'] = entry[0]
     # get the "real" username
     value = passwd.attmap.get_rdn_value(entry[0], 'uid')
     if not value:
         # get the username from the uid attribute
         values = entry[1]['uid']
         if not values or not values[0]:
             logging.warning('%s: is missing a %s attribute', entry[0],
                             passwd.attmap['uid'])
         value = values[0]
     # check the username
     if value and not common.is_valid_name(value):
         raise ValueError('%s: has invalid %s attribute', entry[0],
                          passwd.attmap['uid'])
     # check if the username is different and update it if needed
     if value != parameters['username']:
         logging.info('username changed from %r to %r',
                      parameters['username'], value)
         parameters['username'] = value
Example #3
0
 def validate_request(self, parameters):
     """This method checks the provided username for validity and fills
     in the DN if needed."""
     # check username for validity
     common.validate_name(parameters['username'])
     # look up user DN if not known
     if not parameters['userdn']:
         entry = passwd.uid2entry(self.conn, parameters['username'])
         if not entry:
             raise ValueError('%r: user not found' % parameters['username'])
         # save the DN
         parameters['userdn'] = entry[0]
         # get the "real" username
         value = common.get_rdn_value(entry[0], passwd.attmap['uid'])
         if not value:
             # get the username from the uid attribute
             values = myldap_get_values(entry, passwd.attmap['uid'])
             if not values or not values[0]:
                 logging.warn('%s: is missing a %s attribute', dn, passwd.attmap['uid'])
             value = values[0]
         # check the username
         if value and not common.isvalidname(value):
             raise ValueError('%s: has invalid %s attribute', dn, passwd.attmap['uid'])
         # check if the username is different and update it if needed
         if value != parameters['username']:
             logging.info('username changed from %r to %r', parameters['username'], value)
             parameters['username'] = value
Example #4
0
 def read_parameters(self, fp):
     name = fp.read_string()
     common.validate_name(name)
     return dict(uid=name)
Example #5
0
 def read_parameters(self, fp):
     memberuid = fp.read_string()
     common.validate_name(memberuid)
     return dict(memberUid=memberuid)
Example #6
0
 def read_parameters(self, fp):
     name = fp.read_string()
     common.validate_name(name)
     return dict(cn=name)
Example #7
0
 def read_parameters(self, fp):
     memberuid = fp.read_string()
     common.validate_name(memberuid)
     return dict(memberUid=memberuid)