Integrating Breeze with a directory service
31
8.
For each user listed in the directory service but not in Breeze, add the user to Breeze, as follows:
a
Obtain the user’s first name, last name, and login name from the directory service.
The Breeze login name is usually the user’s e-mail address.
b
Call the
principal-update
action, setting the
type
parameter equal to
user
.
Don’t specify a
principal-id
parameter; leaving out
principal-id
indicates that you are
adding a new user rather than updating an existing user.
c
Check the returned XML to ensure that the status code returned is
"ok"
.
The following code demonstrates how to add a user to Breeze. It uses variables set up in
previous steps of this procedure, such as
baseurl
. To keep the example clear and simple, this
code specifies the user’s information in the first few lines, rather than acquiring that
information from a directory service.
<cfset newlogin= "[email protected]">
<cfset newpass= "abcdefg">
<cfset newfirst= "Jake">
<cfset newlast= "Doe">
<cfhttp url="#baseurl#api/xml?
action=principal-update&accesskey=#accesskey#&first-name=#newfirst#
&last-name=#newlast#&has-children=0&login=#newlogin#
&type=user" method="post">
<cfhttpparam type="Cookie" name="BREEZESESSION" value="#loginCookie#">
</cfhttp>
<!--- Check for an okay status result. --->
<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>
9.
For each user listed in Breeze but not in the directory service, delete the user from Breeze by
calling the
principals-delete
action and specifying the user’s ID. Check the returned XML
to ensure that the status code returned is
"ok"
.
The following code demonstrates how to delete a specified user:
<cfset userID= "503123">
<cfhttp url="#baseurl#api/xml?
action=principals-delete&accesskey=#accesskey#
&principal-id=#userID#" method="post">
<cfhttpparam type="Cookie" name="BREEZESESSION" value="#loginCookie#">
</cfhttp>
<!--- Check for an "ok" status code. --->
<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...