Integrating Breeze with a directory service
29
To synchronize Breeze with the directory service:
1.
Log in by calling the
login
action on the Breeze server, specifying the login name and password
of an account administrator. Examine the returned HTTP headers to find the value of the
BREEZESESSION cookie, which you need when calling subsequent actions.
Note:
Consider creating an administrative user specifically for performing synchronizations. If you
create such a user, you should exclude it from the list of users to synchronize when you perform the
synchronization.
The following code example logs in a user and obtains the cookie value:
<cfset login="[email protected]">
<cfset password="abcdefg">
<cfset accesskey="0123456789101112">
<cfset baseurl="http://breeze.example.com/">
<cfset params="accesskey=#accesskey#&action=login&login=#login#&password=
#password#">
<cfhttp url="#baseurl#api/xml?#params#" method="get">
<cfset loginHeaders= "#cfhttp.ResponseHeader#" />
<cfloop collection="#loginHeaders#" item="httpHeader">
<cfif httpHeader eq "Set-Cookie">
<cfset value= loginHeaders[httpHeader] />
<cfset cookieHeader="#value[1]#" />
<cfloop list="#cookieHeader#" index="c" delimiters=";">
<cfset cookieName= Left(c, Find('=', c)-1) />
<cfif cookieName eq "BREEZESESSION">
<cfset fullCookie= mid(c, len(cook2,
len(c)-len(cook1) />
<cfset loginCookie= Left(fullCookie, Find('.', fullCookie)-1) />
</cfif>
</cfloop>
</cfif>
</cfloop>
2.
Check that the
login
action completed successfully by parsing the returned XML and
examining the value of the
status
tag’s
code
attribute. If the status code isn’t
"ok"
, determine
what the error was and handle it appropriately.
<cfset xml= XmlParse(cfhttp.FileContent)>
<cfset resultsElement= XmlSearch(xml, "//status[@code='ok']")>
<cfif ArrayLen(resultsElement) ne 1>
<!--- No status code "ok" found. Check for other status codes and handle
errors. --->
</cfif>
Содержание BREEZE-USING THE BREEZE XML WEB SERVICES
Страница 1: ...Using the Breeze XML Web Services...
Страница 8: ...8 Contents...
Страница 12: ...12 Introduction Before You Begin...
Страница 26: ...26 Chapter 2 Working with Filters...
Страница 36: ...36 Chapter 3 Common Tasks...
Страница 112: ...112 Chapter 4 Action Reference...
Страница 186: ...186 Chapter 5 XML Results Reference...
Страница 196: ...196 Index...