If you want to add a control to your InfoPath form to do an active directory lookup, then the Contact Selector Control will work for you. In order to add this control to your form, there are some certain guidelines that need to be followed.


To add the control to your form, you first need to make it available in the custom control section of your design controls section. To do so, you need to do the following:

  1. click on the Add or Remove Custom Controls … link
  2. click Add when the dialog box appears
  3. Select ActiveX Control and click Next
  4. A list of controls will appear, scroll down until you find “Contact Selector” and click Next
  5. Select the Don’t include a .cab file, click Next
  6. Select the Value binding property and click Next
  7. In the Field or group type dropdown, select Field or Group (any data type), click Finish


At this point, the control will appear in the Custom section of your controls. Drag the control to your form. You are now ready to configure the control.

If you right click on the contact selector and go to its properties, select the Items tab and it will show you the basic structure of how you need to set up the Data Source group. This is where InfoPath will get picky and will give you problems if you do not follow these guidelines exactly. The Data Source node should be as follows:

MyGroup       {group}
     Person                     {repeating group}
          DisplayName       {field – string}
          AccountId            {field – string}
          AccountType        {field – string}

MyGroup can actually be whatever you want to call it, but the other nodes, need to be spelled EXACTLY the same and are CASE-SENSITIVE!

One last item needs to be added to the form for the control to work. You need to create an empty text document and input the following line of xml into it:

<Context siteUrl=”http://myserver/” />

Save the file as Context.xml and make note of it’s location. Then proceed to create a new Receive web service data connection that points to the XML file you just created and name the Data connection as Context.

That is it, it is ready to go!


As mentioned above, the guidelines need to be followed exactly or you will run into problems with your InfoPath form. If you run your IP form against Design Checker, it will show you that there is no problems, but if you upload the form to SharePoint and try to access the form, you will get an error. Here are some factors that would cause your form to not render correctly if you’ve added the Contact Selector control to your form:

  1. Misspelled one of the data source field nodes in the group your created
  2. Fields are case-sensitive, and weren’t created with the correct case
  3. NO EXTRA fields can be added to the group or repeating group.


If you were to do one of the above mentioned mistakes, you could possibly see this error when you upload your form to SharePoint and use it within a Form Library:











If you were to look at the SharePoint logs, you would see the following error:

Exception Type: System.NullReferenceException  Exception Message: Object reference not set to an instance of an object. 

If this is the case, check to see if you made one of the 3 mistakes above. If you did, make the appropriate change and you should then upload your form again and see it display correctly.