[Freeipa-devel] Newcomer's question

Исаев Виталий Анатольевич isaev at fintech.ru
Mon Sep 16 14:46:49 UTC 2013


Dear Free IPA developers,

Our team is working on the project based on the RHEL Virtualization and RHEL IdM server. It's planned to run our software in enclosed internal enterprise network, and we would like to assign all the authentication and authorization tasks to the FreeIPA Python API. In fact we have already written this part of project on plain C; dialog with IdM server has been implemented over SSH interaction (libssh API + GNU flex). But some time ago we discovered FreeIPA API and since then we really want to migrate from C to Python.

So the time has come, but the problem is our complete ignorance of the Python programming language. We faced a problem trying to modify the tutorial script free-ipa-3.3.1/doc/python-api.py: ldap2 was refused to import. Which module should be included in this case?
We use RHEL 6.4 desktop, all the IPA packages has 3.0.0-25 version.

#!/usr/bin/python
# -*- coding: utf-8 -*-

from ipalib import api, errors
from ipalib import Command
from ipalib import Object
from ipalib import Str
from ipalib import output
from ipalib.plugins import baseldap

#Load environment
api.finalize()
if api.env.in_server:
    api.Backend.ldap2.connect(
        ccache=api.Backend.krb.default_ccname()
     )
else:
    api.Backend.xmlclient.connect()

#Execute command
dn = api.Backend.ldap2.make_dn_from_attr(u'python_dev3', loginshell=u'/bin/sh', givenname=u'Python', sn=u'User', userpassword=u'redhat')
try:
                api.Backend.user_add(dn)
except errors.DuplicateEntry:
                print("Possibly duplicate...")
else:
                print("User added...")

Errors:
ipa: INFO: trying https://ipa.dev.ru/ipa/xml
Traceback (most recent call last):
  File "./test.py", line 22, in <module>
    dn = api.Backend.ldap2.make_dn_from_attr(u'python_dev3', loginshell=u'/bin/sh', givenname=u'Python', sn=u'User', userpassword=u'redhat')
AttributeError: 'NameSpace' object has no attribute 'ldap2'

Thank you,
Виталий Исаев
Инженер-программист
Группа разработки и внедрения ПСЗИ
Департамент информационной безопасности
ОАО <Финтех>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20130916/78894b6f/attachment.htm>


More information about the Freeipa-devel mailing list