I have a infopth document that uses Microsoft Dynamics AX webservices. (WSS 3.0 , Office InfoPatch 2007)
on the load event of the infopath I would like to get some information:
public void FormEvents_Loading(object sender, LoadingEventArgs e)
{
XPathNavigator root = this.MainDataSource.CreateNavigator();
RequestStatusNode = root.SelectSingleNode("/dfs:myFields/dfs:queryFields/tns:createSalesOrder/tns:DocumentContext/tns:SourceEndpointUser", this.NamespaceManager);
RequestStatusNode.SetValue(System.Environment.ExpandEnvironmentVariables("%userdomain%\\%username%"));
}
The page will be placed in a sharepoint site so domain autentication is active:
Now I get this error. According to MS, I have to create a trusted site, but I don't know how. Or is there a more easy way to get the Domain and user info.
System.Security.SecurityException
Request for the permission of type 'System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.ExpandEnvironmentVariables(String name)
at Sales_Order_Entry_Form.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e)
at Microsoft.Office.InfoPath.Internal.FormEventsHost.OnLoad(DocReturnEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnLoad(DocReturnEvent pEvent)