Requirements
See the Crowd install page for specific notes as needed. The Crowd SOAP API requires ZSI to use python to talk to the Crowd server.
Using the Interface
Crowd has a WSDL file that describes the services it provides and this can be used to create a python library needed to talk to Crowd. The
wsdl2py script that is included with ZSI will convert the WSDL file into usable modules though there is little documentation on how to use it from there.
Convert the WSDL file into python
Get the WSDL file from Crowd:
https://idm-dev.unet:8095/crowd/services/SecurityServer?wsdl. At least in Crowd 1.2.2 the WSDL file can't be processed by wsdl2py but there is a work around. See
CWD-159 for details.
wsdl2py -f ./crowd_wsdl.xml
That creates:
- SecurityServer_services.py
- SecurityServer_services_types.py
This code will use those interface classes to communicate through Crowd to AD
from SecurityServer_services import SecurityServerLocator, SecurityServerHttpBindingSOAP
import SecurityServer_services as sss
from SecurityServer_services_types import ns0
loc = SecurityServerLocator()
server = loc.getSecurityServerPortType()
#build up the application authentication token
r = ns0.ApplicationAuthenticationContext_Def('ApplicationAuthenticationContext')
cred = ns0.PasswordCredential_Def('_credential').pyclass()
req = sss.authenticateApplicationRequest()
r._name='soaptest'
cred._credential = 'passwordGoesHere'
r._credential=cred
req._in0 = r
token = server.authenticateApplication( req )
#Look up a principle from the 'soaptest' application
prin = sss.findPrincipalByNameRequest()
prin._in0 = token._out
prin._in1 = 'cpepe'
me = server.findPrincipalByName( prin )
for i in me._out._attributes._SOAPAttribute:
print '%s: %s' % (str(i._name), str(i._values.__dict__))
Resources
- Using wsdl2py in the pylons project
--
ChristopherPepe - 09 Apr 2008