Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow password change #5

Open
b1rger opened this issue Jun 3, 2018 · 0 comments
Open

Allow password change #5

b1rger opened this issue Jun 3, 2018 · 0 comments

Comments

@b1rger
Copy link

b1rger commented Jun 3, 2018

hi,
when i try to use the passwd functionality of ldap, it seems that the default config forbids write access on the userPassword attribute.
With this test script:

import volatildap
import ldap
from django.test import TestCase
from django.utils.crypto import get_random_string

TEST_PASSWORD = 'Passwort123'
TEST_PASSWORD_HASH = '{SSHA}1wZn/TBKLhmQivSjixQi4gdNzFaXrSmp'

people = ('ou=people,dc=example,dc=org', {
    'objectClass': ['top', 'organizationalUnit'],
    'ou': ['people']
    })
wizuser = ('uid=wizuser,ou=people,dc=example,dc=org', {
    'objectClass': ['shadowAccount', 'inetOrgPerson'],
    'uid': ['wizuser-guest'],
    'userPassword': [TEST_PASSWORD_HASH.encode('ascii')],
    'cn': [b'Wiz'],
    'sn': [b'User'],
    'mail': [b'wizuser@example.org']
    })

directory = dict([people, wizuser])

class BaseTestCase(TestCase):
    directory = {}

    @classmethod
    def setUpClass(cls):
        super(BaseTestCase, cls).setUpClass()
        cls.ldap_server = volatildap.LdapServer(
            initial_data=cls.directory,
            schemas=['core.schema', 'cosine.schema', 'inetorgperson.schema', 'nis.schema'],
        )

    @classmethod
    def tearDownClass(cls):
        cls.ldap_server.stop()
        super(BaseTestCase, cls).tearDownClass()

    def setUp(self):
        super(BaseTestCase, self).setUp()
        self.ldap_server.start()

class ConnectionTestCase(BaseTestCase):
    directory = directory

    def test_ldap_passwd(self):
        l = ldap.initialize(self.ldap_server.uri)
        try:
            l.simple_bind_s("uid=wizuser,ou=people,dc=example,dc=org", TEST_PASSWORD)
            l.passwd_s("uid=wizuser,ou=people,dc=example,dc=org", TEST_PASSWORD, get_random_string(32))
            ret = True
        except ldap.LDAPError as e:
            print(e)
            ret = False
        self.assertTrue(ret)

i always get {'desc': 'Insufficient access'} - i tried to add the needed cn=config attributes, but i'm not sure about the syntax. It would be great if volatildap could allow access to the attribute by default or add an option to allow it.

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant