I've read enough about using the forms services to use the built in web service to get the current user, etc. However, I dont want to go that route, nor do I want to call any web service.
I just want to put the code in the form. Everytime I do so though, it bombs out. The code works in Web Apps. I create and even when I debug the code, but once I DEPLOY it, it always throws exceptions when I run it using forms services??? Could it be a security issue? I am giving the form FULL TRUST so I doubt it. I could throw the code in a web service, but don't want to. Code is fine - but it is below. Anyone have any ideas??
Thanks,
private string[] GetRequester()
{
DirectoryEntry entry;
DirectorySearcher myS;string[] props = new string[3];
DirectoryEntry de;entry = new DirectoryEntry("....");
myS =
new DirectorySearcher(entry);string strUserName = System.Environment.UserName;
myS.Filter =
"(&(ObjectClass=user)(SAMAccountName=" + strUserName + "))";SearchResult sc = myS.FindOne();
de = sc.GetDirectoryEntry();
//user's display name
try
{
props[0] = de.Properties["displayName"].Value.ToString().ToUpper();
}
catch
{
props[0] = "";
}
try
{
//extAtt1 = Business Areaprops[1] = de.Properties["extensionAttribute1"].Value.ToString();
}
catch
{
props[1] = "";
}
try
{
//extAtt2 = Vendor Numberprops[2] = de.Properties["extensionAttribute2"].Value.ToString();
}
catch
{
props[2] = "";
}
return props;
}