Thanks for your help Dave.

Yes, the URL is http://IP:8000/EnterpriseController

I don't expect you to do my job for me, but I have included my initial script 
below.  Does anything jump out as being wrong?  My code is probably not the 
best since I am still learning coldfusion.


<!--------------------------------------------------------->
<!--- Expects URL.command                               --->
<!---       Export_Config                               --->
<!---       Import_Config Filename                      --->
<!---       Add_Collection CollectionID CollectionName? --->
<!---       Delete_Collection CollectionID              --->

<!--- Function to check HTTP response for errors and print debug --->
<cffunction name="checkHttpStruct" returnType="boolean">
  <cfargument name="httpStruct" type="Struct" required="yes">
  <cfargument name="stage" type="String" required="yes">

  <cfif LEN(httpStruct.errorDetail) GT 0>
    <cfdump var="#httpStruct.errorDetail#" label="#stage# Error"><BR>
    <cfreturn true>
  </cfif>
  <cfdump var="#httpStruct#" label="#stage# Response"><BR>
  <cfreturn false>
</cffunction>


<!--- Initialize --->
<cfset Variables.error = False>
<cfset Variables.googleWelcome = "Google Mini > Home ">
<cfset Variables.adminUser = "admin">
<cfset Variables.adminPwd = "blahblah">     <!--- TBD HARDCODE get from db --->
<cfset Variables.googleIP = "192.168.0.22"> <!--- TBD HARDCODE Application.cfm 
--->

<!--- Set the URL for the google admin console --->
<cfset Variables.url = "http://#Variables.googleIP#:8000/EnterpriseController";>

<!--- Send initial request to google.  This is just to get a response --->
<cfhttp method="GET" url="#Variables.url#" result="Variables.response"></cfhttp>
<cfset Variables.error = checkHttpStruct(Variables.response, "Initial Request")>

<cfif NOT Variables.error>
  <!--- Get the cookie from the response object. This is the cookie that  --->
  <!--- we are going to echo back in subsequent CFHttp requests.          --->
  <!--- The google cookie will look like:  S=enterprise=XXXXXXXX; PATH=/; --->
  <!---      where XXXXXXXX is a unique key                               --->
  <cfset Variables.googleCookie = 
Variables.response.ResponseHeader["Set-Cookie"]>

  <!--- We dont care about the PATH so just get the first item from the cookie 
--->
  <!--- (take the string before the first semi-colon) --->
  <cfset Variables.NameAndValue = ListGetAt(Variables.googleCookie,1,";")>

  <!--- The name is everything before the first equal sign (chr(61) --->
  <!--- Will be S given the Cookie is S=enterprise=XXXXXXXX --->
  <cfset Variables.cName = ListFirst(Variables.NameAndValue, chr(61))>

  <!--- The value is everything after the first equal sign  --->
  <!--- Will be enterprise=XXXXXXXX given the Cookie is S=enterprise=XXXXXXXX 
--->
  <cfset Variables.cValue = ListRest(Variables.NameAndValue, chr(61))>

  <!--- Send a reload request to get past the initial screen --->
  <!--- that tells you to enable cookies in your browser --->
  <cfhttp method="POST" url="#Variables.url#" result="Variables.response">
    <cfhttpparam name="actionType"        type="URL"    value="reload">
    <cfhttpparam name="#Variables.cName#" type="COOKIE" 
value="#Variables.cValue#">
  </cfhttp>
  <cfset Variables.error = checkHttpStruct(Variables.response, "Reload 
Request")>
</cfif>

<cfif NOT Variables.error>
  <!--- Try to login --->
  <cfhttp method="POST" url="#Variables.url#" result="Variables.response">
    <cfhttpparam name="actionType"      type="URL"    value="authenticateUser">
    <cfhttpparam name="userName"        type="URL"    
value="#Variables.adminUser#">
    <cfhttpparam name="password"        type="URL"    
value="#Variables.adminPwd#">
    <cfhttpparam name="#Variables.cName#" type="COOKIE" 
value="#Variables.cValue#">
  </cfhttp>
  <cfset Variables.error = checkHttpStruct(Variables.response, "Login Request")>
</cfif>

<cfif NOT Variables.error>
  <!--- Check if we have a successful login by looking for the google welcome 
--->
  <cfif NOT FindNoCase(Variables.googleWelcome, Variables.response.header)>
    <cfoutput>Login Failed</cfoutput><BR>
    <cfset Variables.error = True>
  </cfif>
</cfif>

<cfif NOT Variables.error>
  <cfoutput>Login Success</cfoutput><BR>

  <cfif URL.command EQ "Export_Config">
    <!--- Export Config --->
    <cfhttp  method="POST" url="#Variables.url#" result="Variables.response">
      <cfhttpparam name="actionType"     type="URL"    value="importExport">
      <cfhttpparam name="export"         type="URL"    value="Export 
Configuration">
      <cfhttpparam name="password1"      type="URL"    
value="#Variables.adminPwd#">
      <cfhttpparam name="password2"      type="URL"    
value="#Variables.adminPwd#">
      <cfhttpparam name="#Variables.cName#" type="COOKIE" 
value="#Variables.cValue#">
    </cfhttp>
  <!--- TBD 
  <cfelseif URL.command EQ "Import_Config">
  <cfelseif URL.command EQ "Add_Collection">
  <cfelseif URL.command EQ "Delete_Collection">
  <cfelse>
  TBD --->
  </cfif>
  <cfset Variables.error = checkHttpStruct(Variables.response, "#URL.command#")>

  <!--- Log out --->
  <cfhttp method="POST" url="#Variables.url#" result="Variables.response">
    <cfhttpparam name="actionType" type="URL" value="logout">
  </cfhttp>
  <cfset Variables.error = checkHttpStruct(Variables.response, "Logout 
Request")>
</cfif> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311526
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to