Friday, August 28, 2015

Login with different user Sharepoint 2013

Change the siteurl with yours and it will ask you for the new username and password


YourSite/_layouts/closeConnection.aspx?loginasanotheruser=true

Monday, September 22, 2014

The length of the URL for this request exceeds the configured maxUrlLength value SharePoint 2013 Workflow manager httprequest

Error:The length of the URL for this request exceeds the configured maxUrlLength value in SharePoint 2013 Using Workflow Manger


it can be solved by updating simple change in web.config as below:


<configuration>
  <system.web>
<httpRuntime maxRequestLength="51200" requestValidationMode="2.0" maxUrlLength="2000" /> 
  </system.web>
</configuration>
   

get the url from the browser using javascipt var fullUrl = window.location.pathname + window.location.search;

var fullUrl = window.location.pathname + window.location.search;


Thursday, May 15, 2014

SharePoint Content Database in Suspect Mode

If you are getting this error message while accessing SharePoint

"Cannot connect to the configuration database" 

There can be several reasons for this and some of them are described here with possible solutions
http://support.microsoft.com/kb/823287

but another reason is that when your database goes to suspect mode you will get the same error.

What Does Suspect Mode Means?

There are different reasons for database to go in suspect mode like error in its physical files e.g:- log file.

It is difficult to make database online when made as suspect database. There are several ways we can identify that a database is in suspect mode.


I used the following commands to bring my database online



exec sp_resetstatus DBNAME

ALTER DATABASE DBNAME SET EMERGENCY
GO

ALTER DATABASE DBNAME SET SINGLE_USER
GO


DBCC CheckDB (DBNAME , REPAIR_ALLOW_DATA_LOSS)
GO

ALTER DAtabase DBNAME SET MULTI_USER
GO



examples of these command with DBNAme is


exec sp_resetstatus 'SharePoint_Config_703e926e-d84f-4ab1-941e-308e85137400'
ALTER DATABASE [SharePoint_Config_703e926e-d84f-4ab1-941e-308e85137400] SET EMERGENCY
GO
ALTER DATABASE [SharePoint_Config_703e926e-d84f-4ab1-941e-308e85137400] SET SINGLE_USER
GO
DBCC CheckDB ([SharePoint_Config_703e926e-d84f-4ab1-941e-308e85137400] , REPAIR_ALLOW_DATA_LOSS)
GO

ALTER DAtabase [SharePoint_Config_703e926e-d84f-4ab1-941e-308e85137400] SET MULTI_USER
GO

Friday, February 7, 2014

Get User Info From EmailID SharePoint ClientObject Model

public static string GetUserInfo(string Siteurl,string EmailID)
        {
            string DisplayName = string.Empty;
            try
            {
                ClientContext context = new ClientContext(Siteurl);
                context.Credentials = new System.Net.NetworkCredential("userName", "password", "domain");

                ClientResult<Microsoft.SharePoint.Client.Utilities.PrincipalInfo> persons = Microsoft.SharePoint.Client.Utilities.Utility.ResolvePrincipal(context, context.Web, EmailID, Microsoft.SharePoint.Client.Utilities.PrincipalType.User, Microsoft.SharePoint.Client.Utilities.PrincipalSource.All, null, true);
                context.ExecuteQuery();
                Microsoft.SharePoint.Client.Utilities.PrincipalInfo person = persons.Value;
                string lastFragment = person.LoginName;
                DisplayName = lastFragment.Split('\\').Last();
            }
            catch (Exception checkEx)
            {
                string chckErr = checkEx.Message;
            }
            return DisplayName;

        }

The above method will return me an display name ex:-Doula

where i provide an emailid=doula@doula.com

Check if Site exits using Client Object Model SharePoint

public bool CheckifSiteExits(string Siteurl)
        {
            bool Exits = true;
            try
            {
                ClientContext context = new ClientContext(Siteurl);
                context.Credentials = new System.Net.NetworkCredential("doula", "zoo.why.ace-709", "asiapacific");
                Site mySite = context.Site;
                context.Load(mySite);
                context.ExecuteQuery();
                context.Dispose();
            }
            catch (Exception checkEx)
            {
                string chckErr = checkEx.Message;

                Exits = false;
            }
            return Exits;
        }


 Boolean siteCheck = CheckifSiteExits("http://localhost:1188/sites/234234234234");

            if (siteCheck)
            {
                //output site existed message
            }
            else
            {
                //create site using COM
            }

Tuesday, January 21, 2014

want to save a session variable in httphandler(Use a Variable from HttpHandlers to Other Class)

Inherit a class with

 public class URLRewrite : IHttpModule, IRequiresSessionState

inside BeginRequestEventHandler method (EventHandler)

use as below :

HttpContext.Current.Items["Value"] = HttpContext.Current.Request.Url.AbsoluteUri;

Usage in Other Class
string Value=  (HttpContext.Current.Items["Value"]).ToString();