WPF FAQ - Partial Trust Security

How do I detect permission for a file in a partial trust application ?

This situation occurs when an assembly is used by both windows and XBAP application in a partial trust. The assembly might have permission when used through windows application and the same when used through XBAP application will throw a security exception. To prevent this situation, the permission for a file can be checked using the ‘Demand()’ method on the instance of the desired permission. If a file doesn’t have permission, the Demand() method throws a security exception, else it can be used by the partial trust application.

Permalink
Does permission set of partial trust change in the Local Intranet and Internet?

Yes. The permission set of a partial trust changes based on the zone it is run from. It has more permission when run in local intranet than when run using the internet. In the default permission set of partial trust, the following permissions are restricted when the application is run from the internet.

  • Accessing DNS server.

  • Reading Environment variables.

  • File dialogs other than open file dialogs.

  • Assembly isolation by user.

  • Default printing.

  • Assert granted permission.

Permalink
How to get data from database in XBAP application ?

XBAP application runs with partial trust security and therefore the sandbox does not allow the XBAP application to read data from a database directly. In order to read data from the database, a web service can be used to read the data from the database in the local storage and return the dataset back to the XBAP application.

Permalink