Posted by Ajay Matharu in .Net, Development, Microsoft, Sharepoint, Visual StudioNov 27th, 2009 | No Comments
Last night while developing an event listener custom list, I ran into this error,
SharePoint Error: “The language-neutral solution package was not found”
The solution to this problem is, Restart your visual studio. And it will be back to normal.
Hope this helps
Posted by Ajay Matharu in .Net, ASP.Net, Development, Sharepoint, Technical, TechnologyJul 25th, 2009 | No Comments
Here is the way we can add item level permission for a user on an item,
SPRoleDefinition oUserRole;
SPRoleAssignment oUserRoleAssignment;
SPListItem itm;
SPSite site = null;
SPWeb web = null;
string siteUrl = Request.Url.ToString();
site = new SPSite(siteUrl);
web = site.OpenWeb();
SPGroup grp = web.Groups[groupname];
itm=web.Lists["Shared Documents"].Items[0];
oUserRole = web.RoleDefinitions.GetByType(SPRoleType.Administrator);
oUserRoleAssignment = new SPRoleAssignment(loginName, emailId, userDisplayName, notes);//for user
or
oUserRoleAssignment = new SPRoleAssignment(grp);//for group
oUserRoleAssignment.RoleDefinitionBindings.Add(oUserRole);
itm.RoleAssignments.Add(oUserRoleAssignment);
web.AllowUnsafeUpdates...
Posted by Ajay Matharu in Development, Microsoft, Sharepoint, Technical, TechnologyJun 10th, 2009 | No Comments
Hi Guys,
While working on the Sharepoint, I came across this error “Sharepoint site does not exists at mentioned URL”. On searching something I found that we’ll have to change the URL under the Project Properties.
Enter Sharepoint Site URL
Posted by Ajay Matharu in .Net, ASP.Net, SharepointJun 10th, 2009 | No Comments
Here is the little code that you can use to impersonate any user in sharepoint. This will code will pretend that you are logged in as the user who is impersonated and will be allowed access to all the features and inherits all the rights for that person. This is mainly used to do something for which the impersonating person has rights and you other user do not have rights.
SPWeb web = SPContext.Current.Web.Site.OpenWeb();
SPUser user = web.AllUsers[username];
SPUserToken userToken = user.UserToken;
SPSite site = new SPSite(SPContext.Current.Web.Site.Url.ToString(), userToken);
web = site.OpenWeb();
Here...
Posted by Ajay Matharu in .Net, Development, Sharepoint, Visual StudioMay 15th, 2009 | No Comments
Below is an example on how to write to the SharePoint log files (located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS folder).
catch(Exception e)
{
Microsoft.Office.Server.Diagnostics.PortalLog.LogString(“Exception: {0} – {1}”, e.Message, e.StackTrace);
}