CSharpZealot.com

.Net the C# way
Welcome to

CSharpZealot.com

Sign in | Join | Help
in Search
Sahil Malik Sharepoint 2007 Video Training DVD

ASP.Net Security Policy Files...WindowsPrincipal access

Last post 10-02-2007, 9:55 AM by CSharpZealot. 1 replies.
Sort Posts: Previous Next
  •  09-28-2007, 5:34 AM 179

    ASP.Net Security Policy Files...WindowsPrincipal access

    Hey Guys,

    Somebody may be able to shed some light on a small problem i have.

    Scenario:

    Web Parts and External pages displayed within SharePoint 2007 needs to make calls to get details about the WindowsPrincipal.

    Unfortunately under the default policies that's not allowed. So, via the policy files, which settings do i need to add to the config in order to allow access to the WindowsPrincipal class?

    this is obviously so i can retrieve network domain information...

    ideas? i'm running a wss_medium.config and a wss_minimal.config and a wss_custom.config (hoping these can be added to the wss_custom.config and not the wss_minimal.config)????


    Regards
    Brian H. Madsen - CSharpZealot
    Microsoft MVP Visual Developer ASP/ASP.Net

    blog: http://www.msmvps.com/blogs/brianmadsen
    site: http://www.csharpzealot.com

    Microsoft SQL Server UG Perth - President
    http://www.sqlserver.org.au
  •  10-02-2007, 9:55 AM 180 in reply to 179

    Re: ASP.Net Security Policy Files...WindowsPrincipal access

    Ok, here's the solution to getting permission to call WindowsPrincipal from a web part that hasn't been given full trust.

    Note: it may not be the 100% best implementation, or the most advised, but it's what i did to make it work.

    I located the config file which stores information for minimal trust - this is the file which "limits" execution of classes outside of the Sharepoint install.

    it's called wss_minimaltrust.config. It has a section in it which is called SecurityClasses - in that section add the following:

    <SecurityClass Name="ADPermissions" Description="System.Security.Principal, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

    <SecurityClass Name="ADSecPermissions" Description="System.Security.Permissions.SecurityPermission, mscorlib, version=2.0.0.0, PublicKeyToken=b77a5c561934e089" />

    Then below there you'll see a series of IPermission entries. Add the following:

    <IPermission class="ADPermission" version="1" Unrestricted="true" Flags="Execution, WindowsPrincipal" />
    <IPermission class="ADSecPermissions" version="1" Unrestricted="true" Flags="Execution, WindowsPrincipal" />

    IIS will automatically pick up on the config changes first time it loads so you don't have to restart IIS.

    and there you go, that's how you get access to the WindowsPrincipal class from within a web part that doesn't have full trust (eg. is installed in the GAC).


     


    Regards
    Brian H. Madsen - CSharpZealot
    Microsoft MVP Visual Developer ASP/ASP.Net

    blog: http://www.msmvps.com/blogs/brianmadsen
    site: http://www.csharpzealot.com

    Microsoft SQL Server UG Perth - President
    http://www.sqlserver.org.au
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems