Friday, May 25, 2012

Add FBA Users to Sharepoint 2010 Site





SharePoint Central administration disappeared


I am working on development server and i stopped and started Claims to Windows Token Service

Suddenly Central Administration site was down and the website was completely disappeared from my IIS.

if you are in same problem just execute the below command using stsadm tool

stsadm -o provisionservice -action start -servicetype 
Microsoft.SharePoint.Administration.SPWebService -servicename WSS_Administration

restart the IIS ...that it you are done. now you can see your website in IIS.

The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs. + Sharepoint 2010

Go to IIS Manager>SharePoint Web Services\SecurityTokenserviceapplication
Or
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebServices\SecurityToken\web.config




        

















  
















 <!-- Behavior List: -->
    <behaviors>
      <serviceBehaviors>
        <behavior name="SecurityTokenServiceBehavior" >
          <!-- The serviceMetadata behavior allows one to enable metadata (endpoints, bindings, services) publishing.
               This configuration enables publishing of such data over HTTP GET.
               This does not include metadata about the STS itself such as Claim Types, Keys and other elements to establish a trust.
          -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- Default WCF throttling limits are too low -->
          <serviceThrottling maxConcurrentCalls="65536" maxConcurrentSessions="65536" maxConcurrentInstances="65536" />

          <!—newly added tag to fix this error-->


          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>


Thursday, May 24, 2012

Create Anonymous Access page in Extranet SharePoint Application (FBA)

 Create Anonymous Access page in Extranet SharePoint Application (FBA)

1.    Create Application page in the layouts folder
2.    Change master page default.master to simple.master
3.    Replace Codebehind base class LayoutsPageBase  with UnsecuredLayoutsPageBase
4.    Override AllowAnonymousAccess method
5.    Add a location path tag to webapplication web.config file.

replace DynamicMasterPageFile with MasterPageFile as shown below

remove below code

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationPage1.aspx.cs" Inherits="Membership.ApplicationPage1" DynamicMasterPageFile="~masterurl/default.master" %>


Replace with
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationPage1.aspx.cs" Inherits="Membership.ApplicationPage1" MasterPageFile="~/_layouts/simple.master"   %>


simple.master

This master is used by login and error pages. To customize these pages, a replacement page must be created and stored in the _layouts directory on the server. For more information see Default Master Pages in SharePoint  on MSDN.
Pages using simple.master
·         Login.aspx
·         SignOut.aspx
·         Error.aspx
·         ReqAcc.aspx
·         Confirmation.aspx
·         WebDeleted.aspx
·         AccessDenied.aspx

Learn more about master pages

public partial class ApplicationPage1 : UnsecuredLayoutsPageBase // LayoutsPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected override bool AllowAnonymousAccess
        {
            get
            {
                return true;
            }
        }
    }

Add below tag it to your webapplication web.config file
C:\inetpub\wwwroot\wss\VirtualDirectories\portno
<location path="_layouts/Membership/Applicationpage1.aspx">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
 

Enumerate Site collections and sites

public void GetAllSites()
         {

                SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                //using (SPSite site = new SPSite("http://appsweb02:93"))
                {

                    using (SPWeb web = site.OpenWeb())
                    {

                        SPWebApplication webApplication = site.WebApplication; //SPContext.Current.Site.WebApplication;
                        SPSiteCollection siteCollections = webApplication.Sites;

                        string strRoot = string.Empty;
                        foreach (SPSite siteCollection in siteCollections)
                        {
                            strRoot = "http://" + siteCollection.HostName + ":" + siteCollection.Port;

                            if (!strRoot.Equals(siteCollection.Url))
                            {
                                SPWebCollection collWebsite = siteCollection.AllWebs;
                                foreach (SPWeb subSite in collWebsite)
                                {
                                    //Msg.Text += subSite.Title + "<BR>";     // SPEncode.HtmlEncode(subSite.Title) + "<BR>";
                                    //Console.Write(subSite.Url + "-" + subSite.Title + "\n");

                                    listboxSites.Items.Add(new ListItem(subSite.Title, subSite.Url));
                                    subSite.Close();
                                }
                            }
                            siteCollection.Close();

                        }


                    }
                }
            });
       
         }

Fix Alerts are not working in Moss 2007

here is the post
http://suryapulipati.blogspot.com/2012/05/server-administration-programs-and.html

The server administration programs and the Windows SharePoint Services Web applications on this Web server are not compatible. Ensure that the administration program is the same version as the Web application

alerts are not working for my moss site. I tried a lot and I checked so many blogs and I don’t get the correct answer.
here is workaround
if you are getting below error try to specify server name instead of alternate aceess mapping url
for ex: http://contoso.com
http:moss2server
The server administration programs and the Windows SharePoint Services Web applications on this Web server are not compatible.  Ensure that the administration program is the same version as the Web application

check this command to check whether alerts are enabled for the web application
stsadm -o getproperty -pn alerts-enabled -url http://servername
enable alerts command
stsadm.exe -o setproperty -pn alerts-enabled -pv true  -url http://servername
command for run the job
stsadm.exe -o setproperty  -pn job-immediate-alerts -pv "every 5 minutes" -url http://servername

last step
services> timer service > start/restart  (or)
stsadm.exe -o execadmsvcjobs

Followers