O'Reilly logo

Professional ASP.NET 3.5 Security, Membership, and Role Management with C# and VB by Stefan Schackow, Bilal Haidar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

13.7. Using the Provider in Partial Trust

All the examples shown so far for Active Directory and for ADLDS have been running in full trust. However, if you attempt to use the provider directly in a partial trust environment it will fail. Within the provider's Initialize method, an explicit check is made for Low trust. The provider itself is attributed with a link demand for System.DirectoryServices.DirectoryServicesPermission. Also, each of its public methods is attributed with a full demand for the same permission.

C#

[DirectoryServicesPermission(SecurityAction.LinkDemand, Unrestricted=true)]
[DirectoryServicesPermission(SecurityAction.InheritanceDemand, Unrestricted=true)]
public class ActiveDirectoryMembershipProvider : MembershipProvider
{
...
[DirectoryServicesPermission(SecurityAction.Assert, Unrestricted=true)]
[DirectoryServicesPermission(SecurityAction.Demand, Unrestricted=true)]
[DirectoryServicesPermission(SecurityAction.InheritanceDemand, Unrestricted=true)]
  public override string ResetPassword(string username, string passwordAnswer)
...
}

VB.NET

<DirectoryServicesPermission( _
    SecurityAction.LinkDemand, _
    Unrestricted:=True), _
DirectoryServicesPermission( _
    SecurityAction.InheritanceDemand, _
    Unrestricted:=True)> _
    Public Class ActiveDirectoryMembershipProvider
    Inherits MembershipProvider
...
<DirectoryServicesPermission( _
    SecurityAction.InheritanceDemand, _
    Unrestricted:=True), _
DirectoryServicesPermission( _
    SecurityAction.Assert, _
    Unrestricted:=True), _ DirectoryServicesPermission( ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required