Search This Blog

Total Pageviews

Thursday, October 18, 2012

Package Load Failure : Visual Studio 2008 on Windows Server 2008 R2

If you find the above issue coming up when using Visual Studio 2008 on Windows Server 2008 R2 for SharePoint 2007 development, just say Yes and ensure, VS 2008 SP1 is installed.

Saturday, October 6, 2012

SharePoint 2010 - 101 Code Samples

After a long time back today i got time to blog something interesting for Developers.

SharePoint 2010 - 101 Code Samples

please go through the above sample code.

Wednesday, June 13, 2012

An unexpected error has occurred

Normally within SharePoint if an error occurs we would be receiving quite an unhelpful error message i.e. “An unexpected error has occurred”. It is because by default the detailed error messages are turned off for security reasons.

Here are the steps for getting the full error messages

1)      Go to the SharePoint site for which you would like to enable it.
Most likely to be found at c:\inetpub\wwwroot\wss\VirtualDirectories\... and a sub directory with your web application’s port number.

2)      Locate and open the web.config file for editing.

3)      Find out the following entry
<SafeMode MaxControls=“200“ CallStack=“false“ DirectFileDependencies=“10“TotalFileDependencies=“50“ AllowPageLevelTrace=“false“>

And make following changes to it

<SafeMode MaxControls=“200“ CallStack=“true“ DirectFileDependencies=“10“TotalFileDependencies=“50“ AllowPageLevelTrace=“true“>

4)      And
<customErrors mode=“On“ />
<customErrors mode=“Off“ />

5)      Save and close web.config.

That’s it …

Wednesday, April 18, 2012

AD User Login

AD User Login

protected void btnLogin_Click(object sender, EventArgs e)
string domainname = "domainname";
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, domainname))
// validate the credentials
bool isValid = pc.ValidateCredentials(txtUserName.Text.Trim(), txtPassword.Text.Trim());
if (isValid)
UserPrincipal user = UserPrincipal.FindByIdentity(pc, txtUserName.Text.Trim());
lblstatus.Text = "Welcome " + user.Name + ",";
lblstatus.Text = "Invalid Username or Password.";
catch (Exception ex)
lblstatus.Text = "Invalid Domain";

Wednesday, April 4, 2012

LDAP User Search


DirectoryEntry myOU = new DirectoryEntry("LDAP://DC=msbu,DC=sharepoint,DC=com");DirectorySearcher userSearcher = new DirectorySearcher(myOU);//userSearcher.Filter = "(objectClass=user)";userSearcher.Filter = String.Format("( &(objectClass=user) (name={0}))", txtUserName.Text.Trim() + "*");//Label1.Text = userSearcher.FindAll().Count.ToString ();

foreach (SearchResult srchresult in userSearcher.FindAll())if (srchresult.Properties["name"].Count > 0)new ListItem(Convert.ToString(srchresult.Properties["name"][0])));

Tuesday, March 6, 2012

Client Object Model SDK

CAML Query Helper Class

CAMLManager mgr = new CAMLManager();

mgr.QueryGroups.Add(new QueryGroup("Title", Types.FieldTypes.Text, Types.QueryTypes.Eq, "A Title"));
mgr.QueryGroups.Add(new QueryGroup(Types.JoinTypes.Or, "Title", Types.FieldTypes.Text, Types.QueryTypes.Eq, "Another Title"));

mgr.QueryGroups.Add(new QueryGroup(Types.JoinTypes.And, QueryGroup.MergeTypes.Contain, "Total", Types.FieldTypes.Number, Types.QueryTypes.Geq, "2"));

string caml = mgr.GetCAML();

Will provide the following:
        <FieldRef Name="Title" /><Value Type="Text">A Title</Value>
        <FieldRef Name="Title" /><Value Type="Text">Another Title</Value>
      <FieldRef Name="Total" /><Value Type="Number">2</Value>

Sunday, March 4, 2012

Membership.CreateUser(Loginid, Password, Emailid);

Error : Object Reference not to set an object

1)Continue to rely on SPClaimsAuthMembershipProvider and obtaining HttpContext.Current

Just instantiate the HttContext.Current If it is null:

if (HttpContext.Current == null)
HttpRequest request = new HttpRequest(String.Empty, sp_web.Url, String.Empty);
HttpContext.Current = new HttpContext(request, new HttpResponse(new StringWriter()));

If you instantiated new HttpContext, it would be good to reset it at the end of your methods back to null. Just make sure this happens only if HttpContext.Current was null at the beginning.

2)Working with the SqlMembershipProvider and forgetting about HttpContext.Current issue

What we need is to get the SqlMembershipProvider from registered providers and to start using it.
SqlMembershipProvider sqlMembershipProvider = (SqlMembershipProvider)Membership.Providers["FBAMembershipProvider"];

Bear in mind that you should put the name as it is in your web.config file.

Friday, March 2, 2012

How to store the sharepoint List or List Item within the recycle bin of the site while deleting it programmatically ?

Whenever we delete a sharepoint list or list item from the User Interface it get stored within the recycle bin of the site. But when we delete it programmatically it get's deleted permanently.

So what we can do to store the List or List Item within the recycle bin while deleting it programmatically ?

Generally we use the list.Delete() or item.Delete() method to delete the list or item.
Instead of using the Delete() method we can use the Recycle() method i.e list.Recycle() or item.Recycle(). This will store the item within the recycle bin.

Thursday, February 23, 2012

Rename a stand-alone server

Rename a stand-alone server by using Windows Powershell

To rename a SharePoint Server 2010 stand-alone server, you must use a Windows PowerShell 2.0 cmdlet. There is no user interface option for this action.

To rename a stand-alone server by using Windows PowerShell

  1. Verify that you meet the following minimum requirements: See Add-SPShellAdmin.
  2. On the Start menu, click All Programs.
  3. Click Microsoft SharePoint 2010 Products.
  4. Click SharePoint 2010 Management Shell.
  5. At the Windows PowerShell command prompt, type the following command:
Rename-SPServer [-Identity] <OriginalServerName> -Name <NewServerName>