locked
Hosting ASP .NET 2 applications on WSS 3.0 Error on .NET Namespace Reference RRS feed

  • Question

  • Hi,
    I have a custom asp .net website which a page that uses Sysem.DirectoryServices namespace. It runs fine standalone but when integrated with WSS 3 by copying the application into _layouts folder and called from within a link inside a sharepoint site the page execution breaks on a statement that uses a class from the above mentioned name space.

    I tried adding reference to the assembly in the web.config file of the sharepoint site but that doesn't work. Here is the stack trace :

    An operations error occurred.  

    at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.PropertyValueCollection.PopulateList() at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) at System.DirectoryServices.PropertyCollection.get_Item(String propertyName) at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer() at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit() at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize() at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx() at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate) at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue) at System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue) at main2.GroupMembers(String groupName, String domainName, String userName) at main2.Page_Load(Object sender, EventArgs e) 

    • Edited by Riteshbhai Friday, September 28, 2012 10:33 AM
    Friday, September 28, 2012 10:02 AM

Answers

  • Find below line in web.config:

    <trust level="WSS_Minimal" originUrl="" />
    and set Full instead of WSS_Minimal.


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Friday, September 28, 2012 12:08 PM
    Moderator

All replies

  • Hi,

    I think, your application pool account may not have read permission in AD to read user. Just try to use admin account for your web application, which has admin right.

    Also just change trust level of your web application web.config file from Medium to Full.

    Let us know your result


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Friday, September 28, 2012 10:38 AM
    Moderator
  • Hi Hemendra,

    I have copied the application to _layouts folder without its own web.config file as it should inherit settings from the web.config of the sharepoint site from where it will be called. 

    Also I can confirm the user is admin user so the permission issue may not be the case.

    Thanks for your response, appreciate it.

    Friday, September 28, 2012 10:49 AM
  • Hi,

    >the web.config of the sharepoint site from where it will be called.

    I am talking about sharepoint web.config only not your .net web.config file. Go to c:/inetpub/wwwroot/wss/virtual dir../upir web application port no/web.config

    Here you need to set trust level from medium to full (not sure whether t will work or not but atleast give it a try)

    Also check this thread with code, which is running perfectly in sharepoint.

    http://social.msdn.microsoft.com/Forums/eu/sharepointdevelopment/thread/2ad441d7-960b-4344-b5c3-3d4b18eed368

    Let us know your result


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Friday, September 28, 2012 11:06 AM
    Moderator
  • I have two sections in the web.config of the sharepoint site only for medium and minimum trust level config, there is no config available for full trust.

    <securityPolicy>
          <trustLevel name="WSS_Medium" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\config\wss_mediumtrust.config" />
          <trustLevel name="WSS_Minimal" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\config\wss_minimaltrust.config" />
        </securityPolicy>


    Friday, September 28, 2012 11:49 AM
  • Hi,

    In the sharepoint site web config I only get these security policy tags, nothing for full trust.

    <securityPolicy>
          <trustLevel name="WSS_Medium" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\config\wss_mediumtrust.config" />
          <trustLevel name="WSS_Minimal" policyFile="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\config\wss_minimaltrust.config" />
        </securityPolicy>


    Friday, September 28, 2012 11:52 AM
  • Find below line in web.config:

    <trust level="WSS_Minimal" originUrl="" />
    and set Full instead of WSS_Minimal.


    Cheers, Hemendra-MCTS "Yesterday is just a memory,Tomorrow we may never see"

    Friday, September 28, 2012 12:08 PM
    Moderator
  • Riteshbhai, please mark answers that are helpful.

    Thanks!


    Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)

    Thursday, October 18, 2012 6:08 PM