[Freeipa-devel] right way to connect to DS with Directory Manager creds from the test

Rob Crittenden rcritten at redhat.com
Fri Jul 17 15:17:55 UTC 2015


Oleg Fayans wrote:
> Hi everybody,
>
> What is the right way to connect to the Directory Server using Directory
> Manager credentials from the autotest?
> I need to execute something like
> ldapsearch -D "cn=Directory Manager" -w '<directory_manager_password>'
> -b "cn=IPA Topology Configuration,cn=plugins,cn=config"
> form the python code.
>
> A quick look through the code showed that the following method is
> generally used to connect to ldap:
>
> self.ldapuri = 'ldap://%s' % ipautil.format_netloc(api.env.host)
> self.conn = ldap2(api, ldap_uri=self.ldapuri)
> self.conn.connect()
>
> (See ipatests/test_ipaserver/test_ldap.py)
> But this is an anonymous access.

In that same file is an example on how to do a simple bind with DM 
credentials:

         self.conn = ldap2(shared_instance=False, ldap_uri=self.ldapuri)
         self.conn.connect(bind_dn=DN(('cn', 'directory manager')), 
bind_pw=dm_password)

rob




More information about the Freeipa-devel mailing list