Active Directory Template Part - Mel Balsamo

InfoPath Dev

This Blog


Mel Balsamo

Active Directory Template Part

The Active Directory Web Service is a very powerful tool for retrieving user information in our solutions, making them easier to fill out. What’s even more convenient is the ability to just inject it into our forms in a single mouse-click – and there’s the Active Directory template part.


This blog post details the steps on how to create a template part (XTP) that calls the Active Directory Web Service and retrieves the currently logged in user’s information, as well as the manager’s. Follow along and use the template part as many times as you wish!


 This template part tutorial uses Qdabra’s Active Directory Web Service that comes with DBXL. To download a free DBXL trial, click here.


1)      Open InfoPath and design a new blank template part.

2)      Add the following groups and fields to your main data source:

3)      Design your XTP as shown below:

4)      Add secondary data connections:

a.       Go to Tools > Data Connections > Add.

b.      Create a new connection to receive data from a Web service.

c.       Enter the URL: http://<servername>/QdabraWebService/ADUserInfo.asmx where <servername> is the location where DBXL is installed.

(Note: If you are using the Active Directory Standalone Tool, the URL should be http://<servername>/QdabraAD/ADUserInfo.asmx)

d.      From the list of operations, select GetMyInfo.

e.      Check the box that says “Automatically retrieve data when the form is opened”, then click Finish.

f.        Repeat Steps 4a to 4d to add data connections for the GetUserInfo and GetManagerAlias methods.

·         You can leave the parameters blank as we will specify each of them later as we continue designing our form.

·         For the rest of the methods, uncheck the box that says “Automatically retrieve data when the form is opened”.

g.       When done, exit the data connections wizard.


5)      Configure the EmployeeInfo fields:

a.       Double-click on the EmployeeName field to display its properties.

b.      In the Data tab, click on the fx button to set a default value.

c.       In the Insert Formula window, click the Insert Field or Group button.

d.      Select the secondary data source GetMyInfo from the data source drop-down.

e.      Expand the dataFields node to display Value, and click Filter Data.

f.        Add a filter so that it only displays data when Key is equal to the text displayName.

g.       Click OK until all the dialogs are closed.

h.      Repeat Steps 5a to 5g for the EmployeeEmail field, except that Value should be filtered such that Key is equal to the text mail.

Hint: To view a list of all the Active Directory keys, drag the whole ADProp node (/dfs:myFields/dfs:dataFields/tns:GetMyInfoResponse/tns:GetMyInfoResult/tns:ADProp) as a repeating table onto your form, and then preview.


6)      In the Controls task pane, click to add a button between the Employee Info and the Manager Info table.

7)      Double-click on the button to display its properties.

8)      Label the button as Get Manager Info, and click Rules > Add > Add Action.

9)      Add the following actions to query your manager’s alias using your alias which we obtained through GetMyInfo:

a.       Set the field /dfs:myFields/dfs:queryFields/tns:GetManagerAlias/tns:username to the value of /dfs:myFields/dfs:dataFields/tns:GetMyInfoResponse/tns:GetMyInfoResult/tns:ADProp/tns:Value filtered such that Key is equal to sAMAccountName.

b.      Query using the GetManagerAlias data connection.

c.       Set the field /dfs:myFields/dfs:queryFields/tns:GetUserInfo/tns:username to the value of  /dfs:myFields/dfs:dataFields/tns:GetManagerAliasResponse/tns:GetManagerAliasResult

d.      Query using the GetUserInfo data connection.

e.      Set the ManagerName field /my:myFields/my:ManagerInfo/my:ManagerName to the value of /dfs:myFields/dfs:dataFields/tns:GetUserInfoResponse/tns:GetUserInfoResult/tns:ADProp/tns:Value filtered such that Key is equal to displayName.

f.        Set the ManagerEmail field to the value of /dfs:myFields/dfs:dataFields/tns:GetUserInfoResponse/tns:GetUserInfoResult/tns:ADProp/tns:Value filtered such that Key is equal to mail.


Your button rules should be similar to this:


10)   Still in the button properties window, go to the Display tab > Conditional Formatting > Add.

11)   Add the following conditions to disable the button if the Employee Info fields are blank:

12)   Click OK to close all the dialogs.

13)   Preview your template part. The Employee Information table will auto populate with your Active Directory Information. Clicking the Get Manager Info button retrieves your manager’s info as well.

14)   Save your template part.



For you to be able to use it in your forms, you must first install the template part in InfoPath. Here are the steps to do that: 


    1. In InfoPath Design mode, click Controls in the task pane, and scroll down to the Custom section found at the very bottom of the task pane.
    2. If you haven’t installed any custom controls (like template parts), you will see that the Custom section is empty. Click Add or Remove Custom Controls, and then click Add in the dialog box that appears.
    3. In the Add Custom Control Wizard, select Template Part from the options and click Next.
    4. Browse to the path of your template part, and click Finish then Close when done.
    5. The template part will now show in the list of your installed template parts. Click OK to close the dialog box.
    6. After successful installation, the template part will now be available in the Custom section of the Controls task pane.

To use it in your form, just click the template part and it will be shown on InfoPath’s design area. You can then continue designing your form and edit the sections in the template part as necessary.


Additional Info:

If you have added a template part to InfoPath as a custom control, modifying the template part will not change the control. You have to uninstall the current version from your custom controls in InfoPath (using Add or Remove Custom Controls) and then add your new version.


In a real working environment, you must send the updated template part to anyone who is using the original. After the updated template part is installed on each computer, the users are notified that an update is available, thus the need to update the existing forms that are using the template part.


*** The Active Directory template part is included in the Active Directory Standalone Tool. Click here to purchase the tool. ***




Links (3/26/2009) « Steve Pietrek - Everything SharePoint and Office said:

Pingback from  Links (3/26/2009) &laquo; Steve Pietrek - Everything SharePoint and Office

March 26, 2009 3:24 PM

Ernesto Machado said:

Qdabra’s Active Directory Web Service allows you to obtain the manager’s alias for a given username.

April 27, 2009 9:55 AM
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.