ColdFusion

From Rackspace Email & Apps API
Jump to: navigation, search

This is a very simple ColdFusion script that adds a new user & sets the "uid" LDAP attribute for that user.

Notice that the last variable passed to the function is passed as a reference instead of passing the contents of the variable. This is because the SOAP server expects a reference in some cases. When looking at the WSDL file for the function you'd like to use, if one parameter name appears in both the function call and in the response to the function call, that variable is supposed to be passed by reference.

<cfset member_id = "123456">
<cfset admin_user = "someadmin">
<cfset admin_pw   = "somepasswd">
<cfset host_name  = "somedomain.com">
<cfset username = "myuser">
<cfset last_name = "smith">
<cfset password = "somepassword">

<cfset myStr = "uid#Chr(9)##member_id#"> 

      <!--- Add new user account --->
      <cfinvoke webservice="http://admin.webmail.us/excedentsoap/excedentsoap.wsdl"
         method="AddUserWithLdapAttributesString"
         returnvariable="rspAddUser">
          <cfinvokeargument name="ResellerUsername" value="#admin_user#"/>
          <cfinvokeargument name="ResellerPassword" value="#admin_pw#"/>
          <cfinvokeargument name="HostName" value="#host_name#"/>
          <cfinvokeargument name="UserID" value="#username#"/>
          <cfinvokeargument name="Surname" value="#last_name#" />
          <cfinvokeargument name="Password" value="#password#" />           
          <cfinvokeargument name="SetActive" value="1" />
          <cfinvokeargument name="AttributesArrayStr" value="myStr" />             
      </cfinvoke>

<cfoutput>#rspAddUser#</cfoutput>
<cfoutput>#myStr#</cfoutput>