Jul 25th, 2009 | No Comments

Here is the query that will help you to find a particular column in the database. This query will return you the table name in which that column is found.

select so.name, sc.name
from syscolumns sc
inner join sysobjects so on sc.id = so.id
where sc.name = 'SystemColumn'

Written by Ajay Matharu

July 25th, 2009 at 12:03 pm

Jul 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 = true;
itm.Update();
web.Update();
web.AllowUnsafeUpdates = false;

This is useful for setting item level permission via code.

Written by Ajay Matharu

July 25th, 2009 at 12:03 pm