UserExist() return’s false when email id is greater than 120 characters

So, In SharePoint 2010 when you have forms authentication enabled. You can register new users with email ids upto 250 characters as provisioned in User Profile Database at back end.

The problem occurs when you want to check if the user exists using SharePoint OOB function UserExist on ProfileManager class.

It Does not validates the user even after successful registration.
After 3 days of mind operation when I tried decompiling UserProfile.dll I found that the function calls another function GetGuid() which in turns call a Stored Procedure dbo.profile_GetUserGUID. And after checking the Stored Procedure definition it was found that the max limit of incoming account name is set to 120 characters.

Uffff… This is a MicroSoft SharePoint Bug.

Thanks

Advertisements

Iterate all webs in site collection

Below is the code to iterate all webs under a site collection.

private static void ItetrateAllWebsInSiteCollection()
{
using (SPSite oSPsite = new SPSite("http://sitecollectionurl"))
{
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
Console.WriteLine(oSPWeb.Url);
if (oSPWeb.Webs.Count > 0)
{
CheckIfSubSiteExsist(oSPWeb);
}
}
}
}
private static void CheckIfSubSiteExsist(SPWeb oSPWeb)
{
foreach (SPWeb web in oSPWeb.Webs)
{
if (web.Webs.Count > 0)
{
CheckIfSubSiteExsist(web);
}
Console.WriteLine(web.Url);
web.Dispose();
}
}

HTML 5 Video Tag not working in SharePoint

So, The issue here is that HTML 5 Video tag does not work when hosted in SharePoint library.

Issue resolution is to enable Blob cache and make sure mp4 is listed in path variable

  1. Open your web.config.
  1. Search for “blobcache”.
  1. Set “enable” to True.
  1. Set “maxsize” to 5. (Optional. In this step 5 means 5 Gb of cache is allowed)
  1. Ensure that mp4 is listed in “path” value.

Other option is to host your mp4 video outside SharePoint.

SharePoint Migration: Missing Site Templates

That day when I was migrating SharePoint site from 2007 to 2013.  The site was using FAB40Site templates.

After installing FAB 40 version for SP 2010/2013 from here, I got an issue after visual upgrade as described below.

Error: Unfortunately we found some problems. Missing Site Templates.

Site-Template-SP2013

After so much searching no resolution was found on internet.

Resolution:

As the issue didn’t came for SP2010 visual upgrade, It means the templates were present for version 2010. Hence, I  went to 14 hive Templates folder and copied the missing templates folder (LL, PROJSING in this case) to 15 hive Templates folder.

Again run the Visual Upgrade and mission was accomplished.

Anounymous access SharePoint 2010 list data using JavaScript client object model

Below is the PowerShell script to access the data of SharePoint list from webparts using JavaScript client object model Anonymously.

$webapp = Get-SPWebApplication "http://spsite"
$webapp.ClientCallableSettings.AnonymousRestrictedTypes.Remove([microsoft.sharepoint.splist], "GetItems")
$webapp.Update()

Note:

  • Just replace http://spsite with your WebApplication url.
  • “GetItems” remain the same.
  • “AnonymousRestrictedTypes.Add for reversing the changes”

Get SharePoint list item attachments using lists.asmx

In this post we will learn how can we get attachments of a list item from SharePoint using OOB list.asmx service provided by SharePoint.

Assuming you have added service reference in you project, Below is the code:

Where ->

id: The item id whose attachments are to fetched.

Kz: The service object.

ListServiceUrl: Is the key forservice url for example http:///_vti_bin/Lists.asmx

sourcelist: Is the name of the list whose item’s attachments are to be fetched.

GetXElement definition is also given below:

The function would return Key value pairs with file name as key and it’s data as value.

public static List<KeyValuePair<string, byte[]>> GetAttachementsall(string id)
{
var attch = new List<KeyValuePair<string, byte[]>>();
try{
Kz.Lists listService1 = new Kz.Lists();
listService1.Url = ConfigurationManager.AppSettings["ListServiceUrl"];
listService1.UseDefaultCredentials = true;

XmlNode retNode1 = listService1.GetAttachmentCollection(ConfigurationManager.AppSettings["sourcelist"], id);

XElement xl = GetXElement(retNode1);
XNamespace s = "http://schemas.microsoft.com/sharepoint/soap/ ";

var items = from i in xl.Elements(s + "Attachment") select new { File = i.Value };

WebClient Client = new WebClient();
Client.UseDefaultCredentials = true;

foreach (var item in items){

byte[] data = Client.DownloadData(item.File);
string fileName = Path.GetFileName(item.File);
attch.Add(new KeyValuePair<string, byte[]>(fileName, data));

}

}
catch (Exception ex){
Log.WritetoLog("Exception in Getting Attachments " + ex);
}
return attch;

}

public static XElement GetXElement(XmlNode node){
XDocument xDoc = null;
try{
xDoc = new XDocument();
using (XmlWriter xmlWriter = xDoc.CreateWriter())
node.WriteTo(xmlWriter);
}
catch (Exception ex){
Log.WritetoLog("Exception in Converting to Xelement " + ex);
}
return xDoc.Root;
}

Let me know if their are any questions left.

Keep SharePointing..