in

InfoPath Dev

How To Query the Active Directory Web Service

Downloads: 80 File Size: 220kB
Posted By: ErnestoM Views: 263
Date Added: 07-22-2008

The Active Directory Service supports two methods: GetUserInfo and GetMyInfo. This document will show you how to set up a sample form that queries GetUserInfo with a user-entered username string. For a fully-formatted Word document, click the Download button above.

Setup the Active Directory Web Service

1. To confirm that the Active Directory Web Service is working on your server, open Internet Explorer from the machine where DBXL is installed and navigate to the Web Service page on http://<servername>/QdabraWebService/ADUserInfo.asmx

 
Figure 1

2. Click the GetMyInfo link.
3. Click the Invoke link.
4. A new Internet Explorer window will open and display the user information.

Query GetUserInfo

1. Open InfoPath and choose to Design a new blank form.
2. Create a new data connection to the Active Directory Web Service:

a. Click on Tools > Data Connections > Add. This will open the Data Connection Wizard.
b. Select Receive Data and click Next.
c. Select To a Web service and click Next.
d. Type in the URL for the Active Directory Web Service (for example http://<servername>/QdabraWebService/ADUserInfo.asmx) and click Next.
e. Select the GetUserInfo method and click Next.
f. In the parameters window, click Next.
g. Do not check Store a copy of the data in the form template and click Next.
h. Uncheck Automatically retrieve data when form is loaded and click Finish.
i. Finally, close the Data Connections window.

3. Create the form using the appropriate fields.

a. Navigate to Data Source in the task pane.
b. Change Main in the dropdown to GetUserInfo (Secondary).
c. Expand the queryFields node until you see username.
d. Drag username from the Data Source to the view.
e. Expand dataFields until you see ADProp.
f. Drag the ADProp node into the view and choose repeating table.


Figure 2

4. Add a Rules button to query the service:

a. Navigate to Controls in the task pane and click Button. This will add a Button control into the view.
b. Double-click the newly added button in the view. Change the label to Run Query.
c. Click Rules, then click Add, then click Add Action.


Figure 3

d. Select Query using a data connection from the dropdown. The data connection created previously will show up in the Data Connection dropdown. Click OK until the dialogs have been closed.

5. See the form in action.

a. Click Preview.
b. Enter the username for a user in your domain, and then click the Run Query button.

The user’s information from your Active Directory will be displayed. This will allow you to see all the Keys available, which we will use in the next section of this document.

Query GetMyInfo

The following steps will illustrate how to set the value of a field in your form to a value returned by the GetMyInfo method of the Active Directory Web.

1. Open InfoPath and choose to Design a new blank form.
2. Create a new data connection to the Active Directory Web Service:

a. Click on Tools > Data Connections > Add. This will open the Data Connection Wizard.
b. Select Receive Data and click Next.
c. Select To a Web service and click Next.
d. Type in the URL for the Active Directory Web Service (for example http://servername/qdabrawebservice/ADUserInfo.asmx) and click Next.
e. Select the GetMyInfo method and click Next.
f. Do not check Store a copy of the data in the form template and click Next.
g. Check Automatically retrieve data when form is loaded and click Finish.
h. Finally, close the Data Connections window.

3. Create the field and the rule to set its value.

a. Navigate to Controls in the task pane and click on Text Box.
b. Double-click on the textbox field in the view.
c. In the Default Value section, click on the fx button to the right.
d. Click Insert Field or Group.
e. Select the GetMyInfo (Secondary) data source from the dropdown.
f. Expand the xml tree to reach the node dataFields/tns:GetMyInfoResponse/GetMyInfoResult/ADProp
g. Select Value and click Filter Data.


Figure 4

h. In the Specify Filter Conditions dialog, click Add.
i. Select Key in the first drop down.
j. Leave the second dropdown set to is equal to.
k. In the third dropdown type the text "cn" (or whatever key you prefer) without the double quotes. Notice that InfoPath adds double quotes after you type and tab out.


Figure 5

l. Click OK to close every dialog.
m. Preview the form. The value for the key you selected is automatically loaded to the textbox.

Comments

No comments exist for this file.
Copyright © 2003-2007 Qdabra Software. All rights reserved.
View our Terms of Use.