System.Security.Exception - InfoPath Dev
in

InfoPath Dev

System.Security.Exception

Last post 03-27-2008 08:21 AM by wenni057. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 03-26-2008 09:20 AM

    • wenni057
    • Not Ranked
      Male
    • Joined on 03-25-2008
    • Netherlands
    • Posts 9

    System.Security.Exception

    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)

     

  • 03-26-2008 10:27 AM In reply to

    Re: System.Security.Exception

    Welcome to the forum.

    If the webservice is on a different server / site then SharePoint you would need cross domain allowed turned on in Central Admin with SP also you need the server in your Intranet security zone in IE.

    Often it is an IE issue since it is what is used for security.

    I would really like to see how you are integrating with Dynamics. I am working with someone and Great Plains right now but if you had a chance I would love to discuss what you are doing and share some notes maybe.

    Send me an email if you are interested.

  • 03-26-2008 12:17 PM In reply to

    • wenni057
    • Not Ranked
      Male
    • Joined on 03-25-2008
    • Netherlands
    • Posts 9

    Re: System.Security.Exception

    Hi I have a c# solution on my weblog

    http://axstart.spaces.live.com/blog/cns!E82F2C8CB173C0A0!242.entry

    Infact I want to generate the header with C# also in infoPath. In my demo situation sharepoint is on the same domain like Dynamics AX.
    these 2 lines make it work for c#

      axCustTableService.Credentials = System.Net.CredentialCache.DefaultCredentials; // Use the current user to authenticate
    AxDocumentContext.SourceEndpointUser    = Environment.ExpandEnvironmentVariables("%userdomain%\\%username%");



     

     

     

  • 03-27-2008 07:39 AM In reply to

    • wenni057
    • Not Ranked
      Male
    • Joined on 03-25-2008
    • Netherlands
    • Posts 9

    Re: System.Security.Exception

    I have tried thisnew EnvironmentPermission(PermissionState.Unrestricted).Assert();
    RequestStatusNode.SetValue(System.Environment.GetEnvironmentVariable("%userdomain%"));

    but it still does not work out. The user will start the infopath document when he is logon in the domain. The AX webservice requires this information to grant access.

    fields to be set on the XML document 

    Message ID:                   GUIDID //is working fine
    Source Endpoint User:    Domain\Username //security trouble
    Source Endpoint:            need for getting the information out of AX  //will be hard coded
    Destination Endpoint:       need for getting the information out of AX //will be hard coded

    any suggestions?


     

  • 03-27-2008 08:15 AM In reply to

    Re: System.Security.Exception

    Have you tried setting up the web service in data connections rather than doing it all in code?

    You have verified that you are getting domain and username correctly before it attempts to send it?

  • 03-27-2008 08:21 AM In reply to

    • wenni057
    • Not Ranked
      Male
    • Joined on 03-25-2008
    • Netherlands
    • Posts 9

    Re: System.Security.Exception

    Whel I have found the solution.

    In InfoPath 2007 You can set on Tools/Form Options the security.

    When this is set to fully trusted and you also have created a sertificate, it is all working.

     

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.