Have you ever wanted to automatically fill in fields in your InfoPath form with user information from AD?  I had to do this recently for an InfoPath form.  The easiest way I found to do this was to use the SharePoint web service.  The only limitations iare that you need to have your SharePoint and AD User synchronization set up and the AD info you need must be syncronized…not all AD fields are linked in the syncronization by default.  This also means this will only work with MOSS (WSS doesn’t have AD syncronization as it is part of Shared Services).To pull this info, take the following steps:

1. Add the web service: http://[SharePointURL]/_vti_bin/UserProfileService.asmx

2. To get the current user:
using System.DirectoryServices;
string CurrentUser = System.Environment.UserName;

This will get the current SharePoint user, not the user currently logged into the computer.

3. Declare the InfoPath fields so you can write to them later:
XPathNavigator fieldAVPName = MyNavigator.SelectSingleNode("/my:myFields/my:Name", NamespaceManager);
4. Get the properties of the user
sharepoint.UserProfileService MyUsers = new sharepoint.UserProfileService();
MyUsers.Credentials = System.Net.CredentialCache.DefaultCredentials;
sharepoint.PropertyData[] propdata;
propdata = MyUsers.GetUserProfileByName(txtCurrentUser);
int NumProperties = propdata.Length;
string txtFirstName = null;
string txtLastName = null;
string txtName = null;
for (int i = 0; i < NumProperties; i++)
if (propdata[i].Name == "FirstName" && propdata[i].Values.Length > 0)
txtFirstName = (string)propdata[i].Values[0].Value;
else if (propdata[i].Name == "LastName" && propdata[i].Values.Length > 0)
txtLastName = (string)propdata[i].Values[0].Value;
else { }
txtName = txtFirstName + " " + txtLastName;

5. Write the data to InfoPath
You can use this with minor modifications to get other AD Properties of the users.