Hi,

please find attached a small python class (generated with asn1ate) which
might help to generate the needed data to send a request to the extdom
plugin directly. This might be useful to write tests.

To generate the base64 encoded data needed e.g. for the ldapexop command
I used:

from pyasn1.codec.der.encoder import encode as der_encoder
from base64 import b64encode
from pyasn1.codec.native.decoder import decode
from s2n_req import ExtdomRequestValue

ad_user = 'aduser'
ad_domain = 'ad.domain'
request_type = 'full'

name = { 'domainname' : ad_domain, 'objectname' : ad_user }
data = { 'name' : name }
r = { 'inputType' : 'name' , 'requestType' : request_type, 'data' : data }

req = decode(r, asn1Spec=ExtdomRequestValue())
der_serialisation = der_encoder(req)
print b64encode(der_serialisation)

(sorry for the bad python)

$ python my_req.py 
MBsKAQIKAQIwEwQJYWQuZG9tYWluBAZhZHVzZXI=

Now you can send the request to the extdom plugin by calling:

ldapexop -x 
2.16.840.1.113730.3.8.10.4.1::MBsKAQIKAQIwEwQJYWQuZG9tYWluBAZhZHVzZXI=

If the user was found ldapexop will return a base64 encoded reply. So
far using e.g. dumpasn1 was sufficient for me to look at the reply
because I mainly used the requests to generate load for the extdom
plugin and didn't cared much about the reply. But if I'll find some time
I might add a class to decode the reply properly later.

HTH

bye,
Sumit
# Auto-generated by asn1ate v.0.6.1.dev0 from s2n_req.asn1
# (last modified on 2018-01-15 15:15:47.250042)

from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful


class NameDomainData(univ.Sequence):
    pass


NameDomainData.componentType = namedtype.NamedTypes(
    namedtype.NamedType('domainname', univ.OctetString()),
    namedtype.NamedType('objectname', univ.OctetString())
)


class PosixGid(univ.Sequence):
    pass


PosixGid.componentType = namedtype.NamedTypes(
    namedtype.NamedType('domainname', univ.OctetString()),
    namedtype.NamedType('gid', univ.Integer())
)


class PosixUid(univ.Sequence):
    pass


PosixUid.componentType = namedtype.NamedTypes(
    namedtype.NamedType('domainname', univ.OctetString()),
    namedtype.NamedType('uid', univ.Integer())
)


class InputData(univ.Choice):
    pass


InputData.componentType = namedtype.NamedTypes(
    namedtype.NamedType('sid', univ.OctetString()),
    namedtype.NamedType('name', NameDomainData()),
    namedtype.NamedType('uid', PosixUid()),
    namedtype.NamedType('gid', PosixGid())
)


class ExtdomRequestValue(univ.Sequence):
    pass


ExtdomRequestValue.componentType = namedtype.NamedTypes(
    namedtype.NamedType('inputType', 
univ.Enumerated(namedValues=namedval.NamedValues(('sid', 1), ('name', 2), 
('posixuid', 3), ('posixgid', 4)))),
    namedtype.NamedType('requestType', 
univ.Enumerated(namedValues=namedval.NamedValues(('simple', 1), ('full', 2), 
('fullwithmembers', 3)))),
    namedtype.NamedType('data', InputData())
)


_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to