Skip to main content

Posts

Showing posts from 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.

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“TotalFileD...

AD User Login

AD User Login protected void btnLogin_Click( object sender, EventArgs e) { string domainname = "domainname" ; try { 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 + "," ; } else { lblstatus.Text = "Invalid Username or Password." ; } } } catch ( Exception ex) { lblstatus.Text = "Invalid Domain" ; } }

LDAP User Search

lstbox1.Items.Clear(); 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 (); { lstbox1.Items.Add( } foreach ( SearchResult srchresult in userSearcher.FindAll()) if (srchresult.Properties[ "name" ].Count > 0) new ListItem ( Convert .ToString(srchresult.Properties[ "name" ][0])));

CAML Query Helper Class

http://sharepointcamlhelper.codeplex.com/ https://camldotnet.svn.codeplex.com/svn/JohnHolliday.Caml.Net/CAML.cs 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: <Where>   <And>     <Or>       <Eq>         <FieldRef Name="Title" /><Value Type="Text">A Title</Value>       </Eq>       <Eq>         <FieldRef Name="Title" /><Value Type="Text">Another Title</Value>     ...
Creating Custom Field for Email Validation http://www.c-sharpcorner.com/uploadfile/Roji.Joy/creating-a-custom-field-type-for-sharepoint-2010-email-validation-field/
Membership.CreateUser(Loginid, Password, Emailid); Error : Object Reference not to set an object Solutions: 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 ...

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.

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 Verify that you meet the following minimum requirements: See  Add-SPShellAdmin . On the  Start  menu, click  All Programs . Click  Microsoft SharePoint 2010 Products . Click  SharePoint 2010 Management Shell . At the Windows PowerShell command prompt, type the following command: Rename-SPServer [-Identity] <OriginalServerName> -Name <NewServerName> http://technet.microsoft.com/en-us/library/cc261986.aspx