Failure to set credentials

From: Philip Colmer (pcolmer_at_newsgroup.nospam)
Date: 07/20/05

  • Next message: Ohad Young: "using impersonation"
    Date: Wed, 20 Jul 2005 15:25:11 +0100
    
    

    I've written a web service that returns some user-specific information. I'm
    calling that web service from an InfoPath form as managed code:

                MsgBox("Calling WhoAmI service", MsgBoxStyle.OKOnly, "OnLoad")
                Try
                    svc.Credentials =
    System.Net.CredentialCache.DefaultCredentials()
                    MsgBox("Set service credentials", MsgBoxStyle.OKOnly,
    "OnLoad")
                    Try
                        _Initials = svc.GetInitials("")
                        MsgBox("Got '" & _Initials & "'", MsgBoxStyle.OKOnly,
    "OnLoad")
                    Catch ex As Exception
                        MsgBox("Failed to get initials: " & ex.ToString,
    MsgBoxStyle.OKOnly, "OnLoad")
                    End Try
                Catch ex As Exception
                    MsgBox("Failed to set credentials: " & ex.ToString,
    MsgBoxStyle.OKOnly, "OnLoad")
                End Try
                svc.Dispose()
                MsgBox("Disposed of service object", MsgBoxStyle.OKOnly,
    "OnLoad")

    If I've got the form on my computer, it works fine - it sets the
    credentials, gets my initials back from the web service & disposes of the
    object. If, however, I publish the form to a SharePoint forms library and
    open the form from there, the call to svc.Credentials fails with:

    System.Security.SecurityException: Request for the permission of type
    System.Security.Permissions. EnvironmentPermission, mscorlib,
    Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.

    The web service is configured to use integrated windows authentication.

    Can anyone tell me how to resolve this, please?

    --Philip


  • Next message: Ohad Young: "using impersonation"