Hi, i am quite new to Infopath. I created a form and want to read the current loged in user from an ActiveDirectory and write it to an expression box. But whatever i do i get all the time the same Error Message.
System.Security.SecurityException
Security error.
at ARF.ARF.OnLoad(DocReturnEvent e)
at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocu mentEventSink2_SinkHelper.OnLoad(DocReturnEvent pEvent)
here is the piece of code i use for the access
string user = System.Environment.UserName;
Code:
IXMLDOMNode nodeUser = thisXDocument.DOM.selectSingleNode("my:myFields/my:user");
DirectoryEntry entry1 = new DirectoryEntry("LDAP://PCNAME");
Object obj1 = entry1.NativeObject
DirectorySearcher searchInitiatorName = new DirectorySearcher(entry1);
searchInitiatorName.Filter = "(sAMAccountName=" + user + ")"
SearchResult result1 = searchInitiatorName.FindOne();
string fullName = result1.Properties["name"][0].ToString();
searchInitiatorName.Dispose();
entry1.Dispose();
nodeUser.text = fullName;
Would be really nice if someone could help me out
Regards[/code]