Ejemplo n.º 1
0
 def test_reset_ldap_password(self):
     user = TestUser("bill")
     mock_ldap.reset()
     fixture = SynchronisingUserAdapter(user)
     fixture.reset_ldap_password()
     self.assertEqual(mock_ldap.ldap_methods_called(),
                      ['initialize', 'simple_bind_s', 'modify_s'])
     self.assertEqual(
         mock_ldap.ldap_methods_called_with_arguments()[2][1], {
             'who': 'uid=bill,ou=users,dc=test',
             'attrs': [(2, 'userPassword', '{SSHA}!')],
         })
Ejemplo n.º 2
0
def reset_ldap_password(username):
    """ Set the user's ldap password to something that can never be entered,
    effectively locking the account. We do not sync these passwords from
    django, because django_auth_ldap sets all new accounts to these
    passwords. """
    
    from django_ldap_pixiedust.user import SynchronisingUserAdapter
    backend = LDAPBackend()
    user = User.objects.get(username=username)
    ldap_user = backend.get_user(user.id)
    sync = SynchronisingUserAdapter(ldap_user)
    sync.reset_ldap_password()
    
Ejemplo n.º 3
0
 def test_user_attrs(self):
     settings.ldap_settings = TestSettings(
         AUTH_LDAP_USER_ATTR_MAP={
             'foo': 'ldap_foo',
             'bar': 'ldap_bar',
         },
         LDAP_PIXIEDUST_DEFAULT_ATTR_MAP={'frob': 'nicate'})
     user = TestUser(username="******",
                     foo='x',
                     bar='y',
                     password='******')
     fixture = SynchronisingUserAdapter(user)
     self.failUnlessEqual(
         fixture.user_attrs(), {
             'ldap_foo': ['x'],
             'ldap_bar': ['y'],
             'frob': ['nicate'],
             'objectClass': ['organizationalPerson', 'inetOrgPerson'],
             'userPassword': ['{SSHA}QkJTQUxU'],
         })
Ejemplo n.º 4
0
 def test_dn(self):
     user = TestUser("bill")
     fixture = SynchronisingUserAdapter(user)
     self.assertEqual(fixture.dn, "uid=bill,ou=users,dc=test")