One of the things everyone who has asked me about this
have in common is that they all work in a Microsoft Active Directory environment
and they all want their form to load Meta data from the current user and
populate their form with that data.
Now, InfoPath and AD do not have a method for creating a
direct connection, but since all of our users also utilize the Microsoft Office
SharePoint Server (MOSS) forms server they can take advantage of other features
and capabilities of MOSS to solve this problem.
MOSS connects to your AD easily and builds a user
profile based on the data stored in AD for each user. This part is easy enough
to perform so I will not elaborate further on that here.
Once your MOSS “recognizes” your users, you can make use
of its web services to retrieve all users list, a specific user profile and also
the current user profile.
Here I will demonstrate how to create a form that loads
current user profile data as stored in AD without writing a bit of code.
The only thing that needs to be done is to define a
connection to a certain web service that already exists in your SharePoint site
out-of-the-box (OOTB).
Step 1: Create a blank form template
1. Click file->design a form template

2. Select “Blank”

3. Click OK
Step 2: Setting up the web service connection
1. Create a new data source connection.
Go to tools –>Data connection

2. In the "Data connections” dialog Click on Add

3. Select create a new connection to - Receive data
Click next

4. Select Web service as the source type

5. Insert the Following web service name:
http://<servername>/_vti_bin/userprofileservice.asmx?wsdl

6. Replace <servername> with your SharePoint
server name and click next
7. From the operations drop down list select
GetUserProfileByName

8. In MOSS, calling this operation without sending a
user name will return current user’s profile.
9. Click "next" keeping the defaults in every screen
until you can hit Finish

10. Close the Data connection window.
Step 3: Viewing and choosing the AD details we wish to
import:
Now, we need to insert the AD information to the correct
fields. To do so, we first need to see what kind of data we can use.
Since the users profile may include different properties
according to your organizations' software and other dependencies, the web
service results returns a set of “name-value” collection that we can use in
order to get the results we need.
So – first, we have to find the “name” of the property
and then we'll use it to get its value from the web service.
Here is how it is done:
1. To see all the available fields click on View ->
Data source

2. In the Data source drop-down select the one we just
created.

3. Expand the DataFields container node and select the
following fields in the results:

4. In the drop-down menu on the selected nodes select
"repeating table" and place it in the form.
5. You now have a repeating table with all data returned
by the web service. To see all the AD fields available to you, Click "preview"
in the tool bar.
|