Showing posts with label SharePoint Object Model. Show all posts
Showing posts with label SharePoint Object Model. Show all posts
Monday, July 23, 2012
Tuesday, January 26, 2010
How to terminate/cancel workflow from SharePoint object model
While terminating or cancelling workflow, it will delete all the tasks from the task list and it will marked task status as “Cancelled” into attached list.
Reference Link:
http://blog.brianfarnhill.com/2008/10/01/how-to-cancel-a-workflow-programmatically/
Reference Link:
http://blog.brianfarnhill.com/2008/10/01/how-to-cancel-a-workflow-programmatically/
Labels:
cancel workflow,
custom workflow,
delete all the tasks from task list,
How to terminate workflow,
How to terminate workflow from object model,
How to terminate/cancel workflow from object model,
How to terminate/cancel workflow from SharePoint object model,
MOSS 2007,
Personal Experience,
SharePoint,
SharePoint Object Model,
task status as cancelled,
terminate workflow,
visual studio workflow,
Visual Studio Workflow - SharePoint
How to get workflow instance for single workflow into listitem
Getting access denied error while updating list items
I was getting access denied error while updating list items, I already tried to put my code into SPSecurity.RunWithElevatedPrivileges delegate, still I was getting error. Below was my actual code.
CODE:
//code line for updating list columns
Listitem.update()
List.Update()
After doing debugging and removing line by line from actual code I have figured out actual problem – the user who has contributor rights(normal user) was getting access denied error, admin users can able to update list without any problem, it’s because of LIST.UPDATE() statement, because contributor rights users don’t have permission to change anything into List settings, they can add/delete list items but they can’t able to change anything into list, after removing LIST.UPDATE() statement from my actual code, all users were able to successfully update the list items.
Enjoy!
CODE:
//code line for updating list columns
Listitem.update()
List.Update()
After doing debugging and removing line by line from actual code I have figured out actual problem – the user who has contributor rights(normal user) was getting access denied error, admin users can able to update list without any problem, it’s because of LIST.UPDATE() statement, because contributor rights users don’t have permission to change anything into List settings, they can add/delete list items but they can’t able to change anything into list, after removing LIST.UPDATE() statement from my actual code, all users were able to successfully update the list items.
Enjoy!
Labels:
Access denied,
access denied in list item,
Getting access denied error while updating list items,
List Settings,
List.Update(),
Listitem.update(),
MOSS 2007,
Personal Experience,
SharePoint,
SharePoint List,
SharePoint Object Model,
SPSecurity.Runwithelevatedprivileges,
SPSecurity.RunWithElevatedPrivileges delegate,
updating list items
ERROR: Workflow failed on start
I was getting below error while starting of workflow.
Workflow:System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation. at System.Workflow.Runtime.WorkflowDefinitionDispenser.ValidateDefinition(Activity root, Boolean isNewType, ITypeProvider typeProvider) at System.Workflow.Runtime.WorkflowDefinitionDispenser.LoadRootActivity(Type workflowType, Boolean createDefinition, Boolean initForRuntime) at System.Workflow.Runtime.WorkflowDefinitionDispenser.GetRootActivity(Type workflowType, Boolean createNew, Boolean initForRuntime) at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext
I spend lots of time to find out exact resolution for workflow failed error, but I couldn’t get solution, below are some of the reference link which talks causing of issue due to migration from visual studio 2005 to 2008 workflow project, but in my case, I have created workflow into visual studio 2008 only, some articles were talking about adding some line into solution project, but that’s also not working for me.
Reference Link:
http://blog.hhebnes.no/?tag=/workflows
http://www.eggheadcafe.com/software/aspnet/31975863/sharepoint-workflow-upgra.aspx
http://geekswithblogs.net/SoftwareDoneRight/archive/2007/12/12/condition-not-found.aspx
At the last for resolving my issue, I have created new workflow file, one thing I have observed here – if I am going to change main default file name for workflow file from workflow.cs to something else, then sometime it will mess up workflow. So I would recommend not changing workflow.cs file name.
:)
Workflow:System.Workflow.ComponentModel.Compiler.WorkflowValidationFailedException: The workflow failed validation. at System.Workflow.Runtime.WorkflowDefinitionDispenser.ValidateDefinition(Activity root, Boolean isNewType, ITypeProvider typeProvider) at System.Workflow.Runtime.WorkflowDefinitionDispenser.LoadRootActivity(Type workflowType, Boolean createDefinition, Boolean initForRuntime) at System.Workflow.Runtime.WorkflowDefinitionDispenser.GetRootActivity(Type workflowType, Boolean createNew, Boolean initForRuntime) at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance) at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext
I spend lots of time to find out exact resolution for workflow failed error, but I couldn’t get solution, below are some of the reference link which talks causing of issue due to migration from visual studio 2005 to 2008 workflow project, but in my case, I have created workflow into visual studio 2008 only, some articles were talking about adding some line into solution project, but that’s also not working for me.
Reference Link:
http://blog.hhebnes.no/?tag=/workflows
http://www.eggheadcafe.com/software/aspnet/31975863/sharepoint-workflow-upgra.aspx
http://geekswithblogs.net/SoftwareDoneRight/archive/2007/12/12/condition-not-found.aspx
At the last for resolving my issue, I have created new workflow file, one thing I have observed here – if I am going to change main default file name for workflow file from workflow.cs to something else, then sometime it will mess up workflow. So I would recommend not changing workflow.cs file name.
:)
Labels:
custom workflow,
migration from visual studio 2005 to 2008 workflow project,
MOSS 2007,
not changing workflow.cs file name,
Personal Experience,
SharePoint,
SharePoint Object Model,
Sharepoint Problems,
starting of workflow,
The workflow failed validation,
visual studio 2005 workflow,
visual studio 2008 workflow,
visual studio workflow,
Visual Studio Workflow - SharePoint,
Workflow Errors,
Workflow failed on start,
workflow.cs
How to get current status of workflow from SharePoint object model
Reference Link:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.workflow.spworkflowstatus.aspx
Sample Code:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.workflow.spworkflowstatus.aspx
Sample Code:
//Obtain a list item
SPWeb thisWeb = SPControl.GetContextWeb(Context);
SPList issuesList = thisWeb.Lists["Customer Issues"];
SPListItem myItem = issuesList.Items[0];
//Get the workflow status value
int WorkflowStatusValue = myItem["MyWorkflow"];
string WorkflowStatusString = System.Enum.GetName
(typeof(SPWorkflowStatus), WorkflowStatusValue);
StatusLabel.Text = "The current status of the workflow is: " +
WorkflowStatusString;
Labels:
custom workflow,
How to get current status of workflow,
How to get current status of workflow from SharePoint object model,
MOSS 2007,
SharePoint,
SharePoint List,
SharePoint Object Model,
SPList,
SPListItem,
SPWEB,
SPWorkflowStatus,
status of workflow,
System.Enum.GetName,
visual studio workflow,
Visual Studio Workflow - SharePoint
Wednesday, December 16, 2009
How to open any documents in EDIT Mode from custom ASPX page
Requirement:
We need to display documents from SharePoint Document Library into custom ASPX page and when user clicks on documents, it needs to open in “EDIT” mode, by default it’s giving user prompt to open documents in “EDIT” or “READ” only mode.
Solution:
We need to put extra JavaScript code which will open document in EDIT mode.
Reference Links:
http://ddkonline.blogspot.com/2007/07/issues-with-sharepoint-2007-checkout.html
http://www.google.com/search?q=dispex+sharepoint
http://mattknott.com/content/blog/2009/08/Stop_DispEx_Redirecting.html
http://dotnetninja.wordpress.com/2009/01/12/how-to-open-sharepoint-documents-in-edit-mode-with-internet-explorer-6-and-windows-xp-without-regfix/
We need to display documents from SharePoint Document Library into custom ASPX page and when user clicks on documents, it needs to open in “EDIT” mode, by default it’s giving user prompt to open documents in “EDIT” or “READ” only mode.
Solution:
We need to put extra JavaScript code which will open document in EDIT mode.
Reference Links:
http://ddkonline.blogspot.com/2007/07/issues-with-sharepoint-2007-checkout.html
http://www.google.com/search?q=dispex+sharepoint
http://mattknott.com/content/blog/2009/08/Stop_DispEx_Redirecting.html
http://dotnetninja.wordpress.com/2009/01/12/how-to-open-sharepoint-documents-in-edit-mode-with-internet-explorer-6-and-windows-xp-without-regfix/
Labels:
custom ASPX page,
DispEx,
DispEx SharePoint,
Document library,
EDIT mode,
How to open any documents in EDIT Mode from custom ASPX page,
JavaScript code,
MOSS 2007,
Personal Experience,
SharePoint 2007,
SharePoint Document Library,
SharePoint List,
SharePoint Object Model
Sunday, July 26, 2009
Error: Invalid data has been used to update the list item. The field you are trying to update may be read only.
I was getting error “Invalid data has been used to update the list item. The field you are trying to update may be read only” when I tried to update list items with incorrect value into People and group field, I was taking value from SharePoint People picker web control and update same values into SharePoint List columns.
Actually we need to pass and assigned value into specific format to people and group data type, below link describes very good and precise information on how to get values from SharePoint people picker control and update into list columns having people data type.
http://dishashah.wordpress.com/2009/06/18/how-to-display-users-to-sharepoint-peoplepicker-and-to-get-data-from-sharepoint-peoplepicker/
Enjoy!!
Actually we need to pass and assigned value into specific format to people and group data type, below link describes very good and precise information on how to get values from SharePoint people picker control and update into list columns having people data type.
http://dishashah.wordpress.com/2009/06/18/how-to-display-users-to-sharepoint-peoplepicker-and-to-get-data-from-sharepoint-peoplepicker/
Enjoy!!
Labels:
disha shah,
Invalid data has been used to update the list item. The field you are trying to update may be read only,
MOSS 2007,
people and group data type,
People and group field,
People picker web control,
Personal Experience,
SharePoint,
SharePoint List,
SharePoint List columns,
SharePoint Object Model,
SharePoint People picker web control
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
I have written web service program to fetch all list names from web application, in that case I was getting access denied error while retrieving Title of SPWEB object.
Error:
at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex) at 'SPWEB.Title' threw an exception of type 'System.UnauthorizedAccessException'
I have found that my current user don’t have access rights to access some of the sites, after giving required access rights my web service program gave me correct output without any errors.
:)
Error:
at Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException(UnauthorizedAccessException ex) at 'SPWEB.Title' threw an exception of type 'System.UnauthorizedAccessException'
I have found that my current user don’t have access rights to access some of the sites, after giving required access rights my web service program gave me correct output without any errors.
:)
Labels:
Access is denied,
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)),
Microsoft.SharePoint.SPGlobal.HandleUnauthorizedAccessException,
MOSS 2007,
Personal Experience,
SharePoint,
SharePoint Object Model,
SharePoint web services,
SPWEB,
UnauthorizedAccessException
Monday, July 20, 2009
Error while updating SharePoint list, “The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again”
This error "The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again" is very common for beginners SharePoint developer, who start developing and digging into SharePoint object model, it’s coming while updating SharePoint list, the cause of error is due to security rights, if we make web.AllowUnsafeUpdates = true and then update the SharePoint list then we won’t get above error.
Sample Code:
Web.AllowUnsafeUpdates = true;
item["Title"]=”Sample”;
item.Update();
Happy Coding !!
Sample Code:
Web.AllowUnsafeUpdates = true;
item["Title"]=”Sample”;
item.Update();
Happy Coding !!
Labels:
and try your operation again,
list item update,
MOSS 2007,
Personal Experience,
refresh the page,
SharePoint,
SharePoint List,
SharePoint Object Model,
The security validation for this page is invalid. Click Back in your Web browser,
web.AllowUnsafeUpdates
Error while updating list items "Cannot complete this action. Please try again."
I was getting error while updating list items; after looking into each code line by line, I have found that error comes due to incorrect syntax near CAML query, I feel that SharePoint didn’t give us good user friendly error message to debug into our code. After making correction, my code work well.
Enjoy!!
Enjoy!!
Wednesday, June 10, 2009
Anonymous access into SharePoint web services
Till now I didn’t find how to anonymous access web services, we can impersonate our SharePoint object model code by writing block of code under SPSecurity.Runwithelevatedprivileges method, I am looking for something like this for my web services code, I tried to find solution from internet, but I didn’t get success.
I can run or authenticate my web service code by passing current user credentials or any custom credentials (user name, password, domain name), but I am looking something different in authentication mode, please reply to me if any of you find some solutions or any alternatives for my challenge problem and I’ll also do same thing.
Thank you very much!
I can run or authenticate my web service code by passing current user credentials or any custom credentials (user name, password, domain name), but I am looking something different in authentication mode, please reply to me if any of you find some solutions or any alternatives for my challenge problem and I’ll also do same thing.
Thank you very much!
Sizes and items limitation for SharePoint List objects
Below are recommended guidelines for creating total # of site collection, webs, document library and many more …
1. Recommended limitation for SharePoint site objects
http://technet.microsoft.com/en-us/library/cc287790.aspx
2. Limitation guidelines for SharePoint 2003 and SharePoint 2007
http://www.sperto.com.ar/fs_files/user_img/articulos/SharePoint%20Limits.pdf
Apart from this article discussion, here is very good link which will describes logical architecture of site collection.
http://www.sharepointblogs.com/llowevad/archive/2007/06/25/site-collection-logical-architecture.aspx
1. Recommended limitation for SharePoint site objects
http://technet.microsoft.com/en-us/library/cc287790.aspx
2. Limitation guidelines for SharePoint 2003 and SharePoint 2007
http://www.sperto.com.ar/fs_files/user_img/articulos/SharePoint%20Limits.pdf
Apart from this article discussion, here is very good link which will describes logical architecture of site collection.
http://www.sharepointblogs.com/llowevad/archive/2007/06/25/site-collection-logical-architecture.aspx
Labels:
Document library,
logical architecture of site collection,
MOSS,
SharePoint,
SharePoint Admin,
SharePoint Architecture,
SharePoint List,
SharePoint Object Model,
SharePoint site objects,
Sizes and items limitation for SharePoint List objects,
SPListItem,
total no of site collection
Friday, May 29, 2009
How to find page/site customization status – Part 2 – with the help of SharePoint object model
I know that if I find my required data/information from SharePoint database then there must be some way to find same thing from object model. So I started debugging SPFile object and tried to see what are the properties exposed by object model, but I didn’t see any properties from code, then I have found some hidden properties which match with ALLDOCS table schema, properties names are "vti_hasdefaultcontent", "vti_setuppath", so after using those hidden SPFile properties, I got my results which match with query results,
Example Code:
SPFile objFile;
string bDefaultContent = (string)objFile.Properties["vti_hasdefaultcontent"];
string strSetupPath = (string)objFile.Properties["vti_setuppath"];
if (strSetupPath == null && bDefaultContent == null)
{
//If code executed and comes into this loop then current Page/File status is customized
//then I can take objFile.File and objFile.URL values
}
Reference Links:
I have found one hidden property name from object model for checking page/site customization
http://stsadm.blogspot.com/2007/09/re-ghosting-pages.html
Hidden Property name from file object
http://www.eggheadcafe.com/conversation.aspx?messageid=29277607&threadid=29254168
Comments are always welcome!!!
Example Code:
SPFile objFile;
string bDefaultContent = (string)objFile.Properties["vti_hasdefaultcontent"];
string strSetupPath = (string)objFile.Properties["vti_setuppath"];
if (strSetupPath == null && bDefaultContent == null)
{
//If code executed and comes into this loop then current Page/File status is customized
//then I can take objFile.File and objFile.URL values
}
Reference Links:
I have found one hidden property name from object model for checking page/site customization
http://stsadm.blogspot.com/2007/09/re-ghosting-pages.html
Hidden Property name from file object
http://www.eggheadcafe.com/conversation.aspx?messageid=29277607&threadid=29254168
Comments are always welcome!!!
How to find page/site customization status – Part 1 – with the help of Content Database Schema
Till now, that was one of my toughest assignment, my requirement was to find all pages which customized or changed from SharePoint designer, visual studio and any editor tool, when I started working on the requirements, I thought that I can easily find page customized status (ghosted/unghosted) from SharePoint object model - page CustomizedPageStatus enumeration, but that flag gave me wrong value, I mean, I can’t see my pages as customized which I created from SharePoint Designer.
At one time, I don’t know what to searched in Google, because I tried all combination of search query to get some useful output, but It didn’t bring me anything, all search result gave me idea and links about ghosting, how to customize page and how to reset to site definition from SharePoint designer, etc…..
After some time, I have found one link which says how to deal and work with SharePoint content database, so I started playing around with content database and I have found out that I can write a query which will give me page customization status, SharePoint stores all the information into database, “ALLDOCS” table has all information regarding page size, version, attached list, modified user, time and many more ….
By looking into schema for ALLDOCS table, I created database query and finally I got my result and I was so happy to see the result :)
Below is sample query which will give us all the pages which customized/created from SharePoint Designer, Visual Studio or any other editor tool.
QUERY:
SELECT
W.Title, W.FullURL,
D.DirName + '/' + D.LeafName as pageName,
TimeLastModified as ModifiedTime,
*
FROM
Alldocs D With (NoLock)
JOIN Webs W With (NoLock)
On W.ID=D.WebID
WHERE
D.hasstream = '1'
and D.extension = 'aspx'
and D.iscurrentversion = '1'
and D.setuppath is NULL
Reference Links:
ALLDOCS table schema – columns and its description
http://msdn.microsoft.com/en-us/library/cc704495.aspx
Database table information to find page customized status
http://sky-soft.net/SkySoft/Documentation/WSS/WSSv3Notes.htm
Information about SharePoint content database
http://www.sharepointu.com/ethan/archive/2007/09/16/inspecting-the-sharepoint-content-database.aspx
Query to find list of documents from site collection
http://stackoverflow.com/questions/213801/sharepoint-2007-sql-query-to-find-a-list-of-documents-in-site-collection
After finding my result from database, I thought to tried into SharePoint object model, here is link for finding page customization status from object model.
At one time, I don’t know what to searched in Google, because I tried all combination of search query to get some useful output, but It didn’t bring me anything, all search result gave me idea and links about ghosting, how to customize page and how to reset to site definition from SharePoint designer, etc…..
After some time, I have found one link which says how to deal and work with SharePoint content database, so I started playing around with content database and I have found out that I can write a query which will give me page customization status, SharePoint stores all the information into database, “ALLDOCS” table has all information regarding page size, version, attached list, modified user, time and many more ….
By looking into schema for ALLDOCS table, I created database query and finally I got my result and I was so happy to see the result :)
Below is sample query which will give us all the pages which customized/created from SharePoint Designer, Visual Studio or any other editor tool.
QUERY:
SELECT
W.Title, W.FullURL,
D.DirName + '/' + D.LeafName as pageName,
TimeLastModified as ModifiedTime,
*
FROM
Alldocs D With (NoLock)
JOIN Webs W With (NoLock)
On W.ID=D.WebID
WHERE
D.hasstream = '1'
and D.extension = 'aspx'
and D.iscurrentversion = '1'
and D.setuppath is NULL
Reference Links:
ALLDOCS table schema – columns and its description
http://msdn.microsoft.com/en-us/library/cc704495.aspx
Database table information to find page customized status
http://sky-soft.net/SkySoft/Documentation/WSS/WSSv3Notes.htm
Information about SharePoint content database
http://www.sharepointu.com/ethan/archive/2007/09/16/inspecting-the-sharepoint-content-database.aspx
Query to find list of documents from site collection
http://stackoverflow.com/questions/213801/sharepoint-2007-sql-query-to-find-a-list-of-documents-in-site-collection
After finding my result from database, I thought to tried into SharePoint object model, here is link for finding page customization status from object model.
Easiest way to find file extension from SPFile Object
We can pass SPFile.Name object into FileInfo Class and get the extension of file. It will returns “.ASPX” or “.HTML” file extension depending upon file object.
Example Code:
SPFile objFile;
string strFileExtension = new FileInfo(objFile.Name).Extension;
Example Code:
SPFile objFile;
string strFileExtension = new FileInfo(objFile.Name).Extension;
Wednesday, May 6, 2009
Challenges while working with object model to access recurring meeting workspace site information
I was faced many challenges while getting all agenda list, document library from recurring meeting workspace site, because when we are accessing recurring meeting workspace into object model by SPList and other object, we are only getting data of first meeting instance ID, we are not able to loop through all instance at one place.
Many of the people were facing same problem like me, here is one of the link http://www.eggheadcafe.com/forumarchives/Sharepointwindowsservices/Aug2005/post23625925.asp
I did lots of search on internet and finally I found one line of code from which I got some direction to work on. I followed this link to find my solution, http://www.eggheadcafe.com/forumarchives/Sharepointwindowsservicesdevelopment/Sep2005/post23663884.asp
Points to be taken care:
1. There is one hidden list called “Meeting Series” into object model, which will store all the meeting Instance ID, so we need to take each meeting Instance ID from hidden list
2. We need to pass meeting Instance ID to SPQuery object, SPQuery contains property to hold Meeting Instance ID.
Sample Code to find out all data from recurring meeting workspace site:
//Check if current Web is Meeting Workspace then execute below code
if (SPMeeting.IsMeetingWorkspaceWeb(oWeb))
{
//Get Meeting Series list for taking Instance ID of each workspace site
SPList meetingSeriesList = oWeb.Lists["Meeting Series"];
for (int Cnt = 0; Cnt < meetingSeriesList.Items.Count; Cnt++)
{
int InstanceId = Convert.ToInt32(meetingSeriesList.Items[Cnt]["InstanceID"]);
if (InstanceId != 0)
{
// Use SPQuery to set Meeting Instance ID
SPQuery MeetingQry = new SPQuery();
MeetingQry.IncludeMandatoryColumns = true;
MeetingQry.MeetingInstanceId = InstanceId;
//Do Processing of SPQuery Object and get all Agenda List, Document Library data
}
}
}
Many of the people were facing same problem like me, here is one of the link http://www.eggheadcafe.com/forumarchives/Sharepointwindowsservices/Aug2005/post23625925.asp
I did lots of search on internet and finally I found one line of code from which I got some direction to work on. I followed this link to find my solution, http://www.eggheadcafe.com/forumarchives/Sharepointwindowsservicesdevelopment/Sep2005/post23663884.asp
Points to be taken care:
1. There is one hidden list called “Meeting Series” into object model, which will store all the meeting Instance ID, so we need to take each meeting Instance ID from hidden list
2. We need to pass meeting Instance ID to SPQuery object, SPQuery contains property to hold Meeting Instance ID.
Sample Code to find out all data from recurring meeting workspace site:
//Check if current Web is Meeting Workspace then execute below code
if (SPMeeting.IsMeetingWorkspaceWeb(oWeb))
{
//Get Meeting Series list for taking Instance ID of each workspace site
SPList meetingSeriesList = oWeb.Lists["Meeting Series"];
for (int Cnt = 0; Cnt < meetingSeriesList.Items.Count; Cnt++)
{
int InstanceId = Convert.ToInt32(meetingSeriesList.Items[Cnt]["InstanceID"]);
if (InstanceId != 0)
{
// Use SPQuery to set Meeting Instance ID
SPQuery MeetingQry = new SPQuery();
MeetingQry.IncludeMandatoryColumns = true;
MeetingQry.MeetingInstanceId = InstanceId;
//Do Processing of SPQuery Object and get all Agenda List, Document Library data
}
}
}
Labels:
IsMeetingWorkspaceWeb,
meeting instance ID,
Meeting Series,
meeting workspace,
MOSS,
Personal Experience,
recurring meeting workspace,
SharePoint,
SharePoint Meeting Workspace,
SharePoint Object Model,
Sharepoint Problems,
SharePoint security model,
SPQuery
How to get Roles and permission for SharePoint site/web
There are two powerful classes into SharePoint Object model, one is SPRoleAssignmentCollection and second one is SPRoleAssignment, we can use this classes and find permission of any SharePoint objects, starting from Site, Web, Document Libraraies, etc..
Here I am writing sample code to find all the users permission into current web.
Sample Code:
using (SPSite site = new SPSite("http://sitename/"))
{
using (SPWeb objMainWeb = site.OpenWeb())
{
SPRoleAssignmentCollection oRoleAssignments = objMainWeb.RoleAssignments;
foreach (SPRoleAssignment oRoleAssignment in oRoleAssignments)
{
// SPRoleType provide enumaration for finding all user roles like Administrators, Designer, Contributors, Visitors
//check oRoleAssignment.RoleDefinitionBindings.Contains(objMainWeb.RoleDefinitions.GetByType(SPRoleType.Administrator)) value
// if current role is FULL CONTROL/Administrators then it will return TRUE
SPPrincipal oPrincipal = oRoleAssignment.Member;
// oPrincipal object which will return SPuser or SPGroup, depending on current object
}
}
}
Reference Link:
Finding roles and permission for list
http://dotnet.org.za/zlatan/archive/2007/12/23/getting-roles-and-permissions-on-a-list-document-library-level-in-sharepoint-2007-or-wss-3-0.aspx
Get RoleCollection for Web Site
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.roleassignments.aspx
What are the changes in authorization model into WSS 3.0(introduction of new class hierarchy)
http://msdn.microsoft.com/en-us/library/ms469194.aspx
How to get SPUser, SPGroup, SPRole objects
http://forums.asp.net/p/1012092/3068708.aspx
Here I am writing sample code to find all the users permission into current web.
Sample Code:
using (SPSite site = new SPSite("http://sitename/"))
{
using (SPWeb objMainWeb = site.OpenWeb())
{
SPRoleAssignmentCollection oRoleAssignments = objMainWeb.RoleAssignments;
foreach (SPRoleAssignment oRoleAssignment in oRoleAssignments)
{
// SPRoleType provide enumaration for finding all user roles like Administrators, Designer, Contributors, Visitors
//check oRoleAssignment.RoleDefinitionBindings.Contains(objMainWeb.RoleDefinitions.GetByType(SPRoleType.Administrator)) value
// if current role is FULL CONTROL/Administrators then it will return TRUE
SPPrincipal oPrincipal = oRoleAssignment.Member;
// oPrincipal object which will return SPuser or SPGroup, depending on current object
}
}
}
Reference Link:
Finding roles and permission for list
http://dotnet.org.za/zlatan/archive/2007/12/23/getting-roles-and-permissions-on-a-list-document-library-level-in-sharepoint-2007-or-wss-3-0.aspx
Get RoleCollection for Web Site
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.roleassignments.aspx
What are the changes in authorization model into WSS 3.0(introduction of new class hierarchy)
http://msdn.microsoft.com/en-us/library/ms469194.aspx
How to get SPUser, SPGroup, SPRole objects
http://forums.asp.net/p/1012092/3068708.aspx
Subscribe to:
Posts (Atom)