How to get list of users who all are having full access in sharepoint site using client object model c#
Hi,
I want to fetch the list of users who all are having full access to the sharepoint list using client object model with .Net
Please let me know if any property for the user object or any other way to get it.
Thanks in advance.
Here you are complete code i created from some years it lists all groups and users, you can just add a check in the permissions loop to see if it is equal to Full Control.
Private void GetData(object obj)
MyArgs args = obj as MyArgs;
try
if (args == null)
return; // called without parameters or invalid type
using (ClientContext clientContext = new ClientContext(args.URL))
// clientContext.AuthenticationMode = ClientAuthenticationMode.;
NetworkCredential credentials = new NetworkCredential(args.UserName, args.Password, args.Domain);
clientContext.Credentials = credentials;
RoleAssignmentCollection roles = clientContext.Web.RoleAssignments;
ListViewItem lvi;
ListViewItem.ListViewSubItem lvsi;
ListViewItem lvigroup;
ListViewItem.ListViewSubItem lvsigroup;
clientContext.Load(roles);
clientContext.ExecuteQuery();
foreach (RoleAssignment orole in roles)
clientContext.Load(orole.Member);
clientContext.ExecuteQuery();
//name
//MessageBox.Show(orole.Member.LoginName);
lvi = new ListViewItem();
lvi.Text = orole.Member.LoginName;
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = orole.Member.PrincipalType.ToString();
lvi.SubItems.Add(lvsi);
//get the type group or user
// MessageBox.Show(orole.Member.PrincipalType.ToString());
if (orole.Member.PrincipalType.ToString() == "SharePointGroup")
lvigroup = new ListViewItem();
lvigroup.Text = orole.Member.LoginName;
// args.GroupsList.Items.Add(lvigroup);
DoUpdate1(lvigroup);
Group group = clientContext.Web.SiteGroups.GetById(orole.Member.Id);
UserCollection collUser = group.Users;
clientContext.Load(collUser);
clientContext.ExecuteQuery();
foreach (User oUser in collUser)
lvigroup = new ListViewItem();
lvigroup.Text = "";
lvsigroup = new ListViewItem.ListViewSubItem();
lvsigroup.Text = oUser.LoginName;
lvigroup.SubItems.Add(lvsigroup);
//args.GroupsList.Items.Add(lvigroup);
DoUpdate1(lvigroup);
// MessageBox.Show(oUser.LoginName);
RoleDefinitionBindingCollection roleDefsbindings = null;
roleDefsbindings = orole.RoleDefinitionBindings;
clientContext.Load(roleDefsbindings);
clientContext.ExecuteQuery();
//permission level
lvsi = new ListViewItem.ListViewSubItem();
string permissionsstr = string.Empty;
for (int i = 0; i < roleDefsbindings.Count; i++)
if (i == roleDefsbindings.Count - 1)
permissionsstr = permissionsstr += roleDefsbindings[i].Name;
else
permissionsstr = permissionsstr += roleDefsbindings[i].Name + ", ";
lvsi.Text = permissionsstr;
lvi.SubItems.Add(lvsi);
// args.PermissionsList.Items.Add(lvi);
DoUpdate2(lvi);
catch (Exception ex)
MessageBox.Show(ex.Message);
finally
DoUpdate3();
Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation
Similar Messages
-
How to get list of users who reset password using FIM portal
How to get list of users who reset password using FIM portal
-Thanks Rakesh SawantHi Rakesh,
I think you are looking for something like this:
Using Powershell to list all users that had completed
a password reset within the last 30 days
If you found my post helpful, please give it a Helpful vote. If it answered your question, remember to mark it as an Answer. -
To extract the users permission on files and folders in sharepoint 2010 using client object model
To extract the users permission on files and folders in sharepoint 2010 using client object model
Hello,
This is sample code to get item level permisison: (Just written in notepad so it is not tested)
public void ItemLevelPermission()
SecurableObject curObj = null;
ListItem curItem = ctx.Web.Lists.GetByTitle("LibraryName").GetItemById(ItemId); -> Use Id of file or folder.
IEnumerable roles = null;
roles = ctx.LoadQuery(
curObj.RoleAssignments.Include(
roleAsg => roleAsg.Member,
roleAsg => roleAsg.RoleDefinitionBindings.Include(
roleDef => roleDef.Name, // for each role definition, include roleDef’s Name
roleDef => roleDef.Description)));
ctx.ExecuteQuery();
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
I want to change 'Modified By' column value of a file that is being uploaded using Client Object Model in SharePoint 2013. The problem is that the version of the file is changing. Kindly help me. The code that I am using is:
using (System.IO.Stream fileStream = System.IO.File.OpenRead(m_strFilePath))
Microsoft.SharePoint.Client.File.SaveBinaryDirect(m_clientContext, str_URLOfFile, fileStream, true);
Microsoft.SharePoint.Client.File fileUploaded = m_List.RootFolder.Files.GetByUrl(str_URLOfFile);
m_clientContext.Load(fileUploaded);
m_clientContext.ExecuteQuery();
User user1 = m_Web.EnsureUser("User1");
User user2 = m_Web.EnsureUser("User2");
ListItem item = fileUploaded.ListItemAllFields;
fileUploaded.CheckOut();
item["UserDefinedColumn"] = "UserDefinedValue1";
item["Title"] = "UserDefinedValue2";
item["Editor"] = user1;
item["Author"] = user2;
item.Update();
fileUploaded.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);
m_clientContext.ExecuteQuery();Hi talib2608,
Chris is correct for this issue, when calling update using ListItem.update method, it will increase item versions, using SystemUpdate and UpdateOverwriteVersion will update the list item overwrite version.
these two methods are not available in CSOM/REST, only server object model is available for this.
Thanks,
Qiao Wei
TechNet Community Support -
Cannot create list in SharePoint 2010 using Client Object Model
I am trying to utilize SharePoint 2010 Client Object Model to create a List based on a custom template. Here's my code:
public void MakeList(string title, string listTemplateGUID, int localeIdentifier)
string message;
string listUrl;
List newList;
Guid template;
ListCreationInformation listInfo;
Microsoft.SharePoint.Client.ListCollection lists;
try
listUrl = title.Replace(spaceChar, string.Empty);
template = GetListTemplate((uint)localeIdentifier, listTemplateGUID);
listInfo = new ListCreationInformation();
listInfo.Url = listUrl;
listInfo.Title = title;
listInfo.Description = string.Empty;
listInfo.TemplateFeatureId = template;
listInfo.QuickLaunchOption = QuickLaunchOptions.On;
clientContext.Load(site);
clientContext.ExecuteQuery();
lists = site.Lists;
clientContext.Load(lists);
clientContext.ExecuteQuery();
newList = lists.Add(listInfo);
clientContext.ExecuteQuery();
catch (ServerException ex)
Now, this particular part, newList = lists.Add(listInfo); clientContext.ExecuteQuery();, the one that is supposed to create the actual list, throws an exception:
Message: Cannot complete this action. Please try again.
ServerErrorCode: 2130239231
ServerErrorTypeName: Microsoft.SharePoint.SPException
Could anyone please help me realize what am I doing wrong? Thanks.I've made progress - well, at least to some extent. The previous message related to the "Invalid file name" is not appearing any more. I now realize that it is necessary to specify feature ID, list template kind, as well as custom schema in order
to order SharePoint 2010 to create the document library.
However, there's a new problem which isn't documented on the net almost at all (at least I was unable to find anything): The document library gets created, but I cannot access it. Further inspection showed that the doc lib views are not created. Basically,
the only accessible doc lib page is the document library settings page. Also, I get the server exception with the message:
Server Out Of Memory. There is no memory on the server to run your program. Please contact your administrator with this problem.
Any idea what is causing this issue? Thanks.
Hi Boris
Borenović,
I think I found the reason for this notorious "Server Out Of Memory" error.
(Man, it took 4 hrs of frustrating troubleshooting without any direct hints... very disappointing
MSFT developers :( ).
Anyway,
All the "Form" elements at the bottom need to have SetupPath="pages\form.aspx"
attribute (by default this attrib is missing when you copy the whole List element from inside the stp's manifest.xml file).
Also, just make sure that each "View" element has correct "WebPartZoneID", "SetupPath" and "Url" attribute values otherwise that list/library will
be created successfully but will fail to load when you try to access it (with the VERY helpful "Cannot complete this action, contact administrator" error). Even if you enable stack trace (or check ULS logs) you will find "An unexpected
error has been encountered in this Web Part. Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe." and you will never realize it's because of the
incorrect attributes ("WebPartZoneID", "SetupPath" or "Url" as mentioned above).
Come on Microsoft, you can do better than that?
If the API needs this attrib then why is it missing inside the manifest.xml file when
an STP file generated in the first place? -
How to get list of users who have access to a SAP module
Hi,
We are developing a tool in Java where we will pull the data from various modules in SAP (like Purchase order, Invoice etc). Lets take Purchase Order Module as example. I can get the data using BAPIs (like BAPI_PO_GETDETAIL).
However to implement Authorization, I also want the list of users/groups that have access to Purchase order module. Is this possible? Or can we get the ACL information from the tables in database like EKKO for Purchase order?
I have tried searching for solution but couldn't find any. Please suggest if there is some standard way by which we can pull the ACL information via Java, or if this can be achieved by some custom RFCs.
Thanks,
AnuragAnurag,
The best way is to wirte a RFC Function Module (It will fetch the roles of the user from agr_users table) which will take user id as import paramter and will give you assigned roles.
Please let me know if you still need any further information.
Thanks,
Hamendra -
How to connect sharepoint online using client object model and authentictae against window login
Iam developing A console application where in need to connect to sharepoint online and authenticate against window login can u please suggest me the code
Hi,
There is couple of helper method to check and validate the SPO credentials in the same solution.
string userName = GetUserName();
SecureString pwd = GetPassword();
/* End Program if no Credentials */
if (string.IsNullOrEmpty(userName) || (pwd == null))
return;
// Open connection to Office365 tenant
ClientContext cc = new ClientContext(siteUrl);
cc.AuthenticationMode = ClientAuthenticationMode.Default;
cc.Credentials = new SharePointOnlineCredentials(userName, pwd);
if you give incorrect user name or password it will throws an exception in the console.
Murugesa Pandian.,SharePoint 2010 MCPD | MCTS|Configure -
How to activate Custom Feature in SharePoint 2010 using Client Object model
I am trying to Activate a custom feature using Client Object Model in SharePoint 2010. Here is the code I used. When I execute the code, I got the error "Feature with Id 'xx' is not installed in this farm, and cannot be added to this scope while
creating site collection". Can anyone help?
ClientContext clientContext = new ClientContext(spURL);
//GUID of the custom feature
Guid districtFeatureId = new Guid("5b3529de-5045-46da-af87-8d2e32c121a7");
Site clientSite = clientContext.Site;
FeatureCollection clientSiteFeatures = clientSite.Features;
clientContext.Load(clientSiteFeatures);
clientContext.ExecuteQuery();
//Activate the feature
clientSiteFeatures.Add(districtFeatureId, false, FeatureDefinitionScope.Site);
clientContext.ExecuteQuery();Hi shil chan,
When you activate a feature on the site collection, the feature should be scoped to site or farm, the error message shows it cannot find the specific feature, this will happen when you have a feature in web
scope or the feature isn’t installed.
So, to troubleshooting this issue:
Verify whether the feature is scoped to web. Please go to
Site Setting->Site Features . If the feature is a web scope feature, then add the feature to webfeatures.
Make sure the feature is installed correctly.
Please inform me freely if you have any questions.
Thanks -
Hi, We need a list of users that visits a certain page on a SharePoint site on a daily, weekly and monthly basis.
Now the question is, is that possible out of the box or through the custom web development.
Thanks
RRSHi,
Hope this will help you.
http://sharepoint.stackexchange.com/questions/83640/how-to-check-user-has-visited-site-collection-first-time
http://blogs.msdn.com/b/ecm/archive/2010/05/03/web-analytics-in-sharepoint-2010-insights-into-reports-and-metrics.aspx
Regards,
MS -
Unable to get the SharePoint 2013 List names using Client object model for the input URL
Please can you help with this issue.
We are not able to get the SharePoint 2013 List names using Client object model for the input URL.
What we need is to use default credentials to authenticate user to get only those list which he has access to.
clientContext.Credentials = Net.CredentialCache.DefaultCredentials
But in this case we are getting error saying ‘The remote server returned an error: (401) Unauthorized.’
Instead of passing Default Credentials, if we pass the User credentials using:
clientContext.Credentials = New Net.NetworkCredential("Administrator", "password", "contoso")
It authenticates the user and works fine. Since we are developing a web part, it would not be possible to pass the user credentials. Also, the sample source code works perfectly fine on the SharePoint 2010 environment. We need to get the same functionality
working for SharePoint 2013.
We are also facing the same issue while authenticating PSI(Project Server Interface) Web services for Project Server 2013.
Can you please let us know how we can overcome the above issue? Please let us know if you need any further information from our end on the same.
Sample code is here: http://www.projectsolution.com/Data/Support/MS/SharePointTestApplication.zip
Regards, PJ Mistry (Email: [email protected] | Web: http://www.projectsolution.co.uk | Blog: EPMGuy.com)Hi Mistry,
I sure that CSOM will authenticate without passing the
"clientContext.Credentials = Net.CredentialCache.DefaultCredentials" by default. It will take the current login user credentials by default. For more details about the CSOM operations refer the below link.
http://msdn.microsoft.com/en-us/library/office/fp179912.aspx
-- Vadivelu B Life with SharePoint -
How to Enable Ratings on SharePoint List using Client Object Model code for Office 365 SharePoint Site.
Thanks in Advance
Rajendra KHi Rajendra,
here you are the code and the blog, let me know if this helps
using (ClientContext ctx = new ClientContext(https://yourSiteUrl))
Web w = ctx.Web;
List l = w.Lists.GetByTitle("yourListName");
ctx.Load(l, info => info.Id);
ctx.ExecuteQuery();
string ListID = l.Id.ToString();
Microsoft.Office.Server.ReputationModel.Reputation.SetRating(ctx, ListID, 1, 5);
ctx.ExecuteQuery();
http://blogs.technet.com/b/speschka/archive/2013/07/08/how-to-use-csom-with-ratings-in-sharepoint-2013.aspx
Kind Regards, John Naguib Technical Consultant/Architect MCITP, MCPD, MCTS, MCT, TOGAF 9 Foundation -
Assign Group permission to list item using client object model
Hi,
I am trying to add the list item and assign the permission to the list item by using SP 2010 client object model. The problem which i am facing that when i assign the group as a permission to the item, by automatically the limited access permission
is added to the group. Please find the steps which i have followed,
Step-1: Break role inheritance.
foreach (var item in _listItemCollection)
if (item["FileLeafRef"].ToString().ToLower() == "xxx")
item.BreakRoleInheritance(true, false);
_clientContext.Load(item.RoleAssignments);
_folderItem = item;
_clientContext.ExecuteQuery();
Step 2: Remove all permissions of the list item.
foreach (var assignment in _folderItem.RoleAssignments)
assignment.RoleDefinitionBindings.RemoveAll();
assignment.Update();
_clientContext.ExecuteQuery();
Step 3:
Add Group as a permission to the list item.
var role = _web.RoleDefinitions.GetByType(RoleType.Contributor);
var collRdb = new RoleDefinitionBindingCollection(_clientContext) { role };
Principal principal = _grp;
_folderItem.RoleAssignments.Add(principal, collRdb);
_folderItem.Update();
_clientContext.ExecuteQuery();
After adding the group successfully to the list item, i checked the group permission and it contains the value as "Contribute,Limited Access" to the site level and "Contribute" to the list item. Please guide me how to avoid to create Contribute,Limited
Access role.
BalajiHi Dmitry,
When I create the group and assign contribute permission, the group has the permission at the site level(to see the permission, click group and click view Group Permission). I have added the list item and break the role inheritance permission
and given the unique permission by providing group as a permission to the list item. After providing the permission, the group permission at the site level changed to "Contribute, Limited Access". I dont know how contribute permission changed to contribute,
limited access.
I found the workaround to fix this issue. I created the group and create the folder in the shared document library by using client object model. Due to facing some issue by providing the permission using client object model, i have created the event receiver
to the document library and using server object model, i can able to assign the approprate group permission.
Balaji -
How to get list of users assinged the same product catagory
Hi All ,
we have a requirement in which we need to get the list of users who are assigned the same product category.
ie if we give the prod category 14000000 then we need the list of users assigned the 14000000 prod category.
is any FM available.
please help.
Regards
Channappa SajjanarHi Chinnappa,
1) You can create a table query for tables HRT1222 and HRP1222 to get the org Id or Position Id assigned for the product category.
Then use FM BBP_OM_STRUC_GET_USER_FROM_POS to get the list of users for that org ID.
2) or if you want to check list of prod categories linked to user ID, then use FM BBP_READ_ATTRIBUTES
rgds,
Ravi -
How to get list of users using IN OIM
Experts,
Is it possible to get the list of users who have logged into OIM in past (for example last six months)? as not all people in my organization uses OIM.
Please suggest if OIM(version 9.1.02) has any such functionality or if it is possible to get it from OIM database.
Thanks,
S MOIM will not store last logon date & time. So this is not possible. If you have access manager integrated environment, then OID will have last logon date & time. in such environment, from OID, you can get these details.
-
How to get the online user who are browse some view?
i want to get the current users who are browsing some view in EP6.additonal:which is developed as web dynpro project.
Hi,
Per my knowledge, we cannot get the SharePoint user context available in custom federated search connector with other methods.
Here is a similar thread for your reference:
https://answers.atlassian.com/questions/263735/atlassian-sharepoint-connector-federated-search-authentication-and-authorization
Thanks,
Linda Li
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Linda Li
TechNet Community Support
Maybe you are looking for
-
WBS & Commitment Code Update in Purchase Order/Down Payment
Sir, We have created purchase orders by using WBS and Commitment Code and afterwards, the down payments has been created against the purchase Orders. Now we want to change the WBS and Commitment Code in Purchase Orders and also in Down Payment Reques
-
BI 7 Inventory Transformations 0IC_C03
Hi, any body implemented Inventory managment in BI 7 flow. we are implemenating Inventory managment in BI 7 flow. issue is when installling transformations most of the keyfigures are not mapped, do we have to map/ write rouitnes, content will not giv
-
Unable to share files in windows 7 to my apple tv
is there settings that i need to change in windows 7 so i can share pictures and stuff with my apple tv? sharing works with my wife's macbook notebook, but not with my pc. i have 2 notebook pcs running windows 7. i have turned on home sharing and i a
-
Using Internal Orders to Capture Vehicle Maintenance.
Dear Experts; Our company has automobiles that are service by a third party. We create service LPOs whenever the vehicle service is due. Once the service is done, a service acceptance is done and payment process. Now we want to use Internal orders to
-
"change over currency in existing company"
Hi Gurus, My client wants to change his currency from CAD to USD for an existing company. Can anybody tell me the impact of changing currency for an existing company to a new currency in a live scenario and configuration settings also. Thanks jais