O
OMAF-Terry
I've posted a few messages here and looked at countless posts but not able to
find a complete solution. I have everything working the way I want all I need
now is to call my web service when the page loads.
One suggestions was to use the data connection method and have it populate
when the form loads but I'm not seeing how to do that when I have a parameter
(System.Environment.UserName) that needs to be passed to the service in order
for it to return value.
Here is the web service method I need to call:
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 username using Active Directory.";
}
string strCurrentUserFullName =
resultFullName.Properties["givenName"][0].ToString() + " " +
resultFullName.Properties["sn"][0].ToString();
return strCurrentUserFullName;
}
Anyone????
find a complete solution. I have everything working the way I want all I need
now is to call my web service when the page loads.
One suggestions was to use the data connection method and have it populate
when the form loads but I'm not seeing how to do that when I have a parameter
(System.Environment.UserName) that needs to be passed to the service in order
for it to return value.
Here is the web service method I need to call:
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 username using Active Directory.";
}
string strCurrentUserFullName =
resultFullName.Properties["givenName"][0].ToString() + " " +
resultFullName.Properties["sn"][0].ToString();
return strCurrentUserFullName;
}
Anyone????