Help with web services...VERY frustrated.

O

OMAF-Terry

I've posted numerous times, searched, searched, searched and can't seem to
get an answer on this.

I have a C# web service that I want to query when infopath form starts. The
web method takes one parameter that is the username of the person using the
form (System.Environment.UserName).

That's all I want but I can't figure out how to do this in C#!

Someone suggested creating the 2nd data source and having the text field
populate onLoad but how do you do that when you need to submit parameter
first?

ANYONE???


Webservice:
=============================================
[WebMethod (Description="Get the full name of the form user.")]
public string getCurrentUserFullName(string localUserName)
{
DirectoryEntry entryFullName = new
DirectoryEntry("LDAP://ou=people,dc=on,dc=ca");
DirectorySearcher dsFullName = new DirectorySearcher(entryFullName);
dsFullName.Filter = "(SAMAccountName=" + localUserName + ")";
dsFullName.PropertiesToLoad.Add("givenName");
dsFullName.PropertiesToLoad.Add("sn");
SearchResult resultFullName = dsFullName.FindOne();

if(resultFullName == null)
{
return "Error finding user " + localUserName + " in Active Directory.";
}

string strCurrentUserFullName =
resultFullName.Properties["givenName"][0].ToString() + " " +
resultFullName.Properties["sn"][0].ToString();
return strCurrentUserFullName;
}
=============================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top