Another way to implement SharePoint anonymously

Source: Internet
Author: User

1. Create a region 82

2. Set membershipprovider

 

Code

  Public     Override     Bool  Validateuser (  String  Username,  String  Password)
{
If (Username = " Guest " )
Return True ;
Else
Return False ;
}

Public Override Membershipuser getuser ( String Username, Bool Userisonline)
{
If (Username = " Guest " )
Return New Membershipuser ( This . Name, " Guest " , " Guest " , String . Empty, String . Empty, String . Empty, True , False , Datetime. minvalue );
Return Null ;
}

Public Override Membershipusercollection getallusers ( Int Pageindex, Int Pagesize, Out Int Totalrecords)
{
Totalrecords = 1 ;
Membershipusercollection usercollection = New Membershipusercollection ();
Usercollection. Add ( New Membershipuser ( This . Name, " Guest " , " Guest " , String . Empty, String . Empty, String . Empty, True , False , Datetime. minvalue ));
Return Usercollection;
}

Public Override Membershipusercollection findusersbyname ( String Usernametomatch, Int Pageindex, Int Pagesize, Out Int Totalrecords)
{
If ( String . Format ( " Guest " ). Contains (usernametomatch ))
Return Getallusers ( 1 , 1 , Out Totalrecords );
Else
{
Totalrecords = 0 ;
Return New Membershipusercollection ();
}
}

 

 

 

3. Configure the 82 site as anonymous access and set membershipprovider

4. Change the 82 global. ashx File

 

Code

  1   <  Script runat  =  '  Server  '  > 
2 Protected Void Application_authenticaterequest (Object sender, eventargs E)
3 {
4 String Cookiename = Formsauthentication. formscookiename;
5 Httpcookie authcookie = Context. Request. Cookies [cookiename];
6 If (Authcookie = Null )
7 {
8 Formsauthentication. setauthcookie ( " Guest " , False );
9 }
10 }
11   </ Script >

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.