How to programmatically check view permission to a url in SharePoint? - sharepoint

I am displaying a list of popular public bookmarks to the logged-in user. Some users dont have access to these bookmark-urls and I want to suppress the results so that only accessible urls are shown to the user.
I tried to use the DoesUserHavePermissions method, but the problem is that I am not sure what object does the url points to (item/list/web/site).

I figured it out :|
when getting popular bookmarks from SocialTagManager i need to pass the logged-in users context i.e. SPServiceContext.Current and SharePoint will take care of the rest.

Related

Is there a way in Sitecore to display a link to a media library item that the user does not have access to?

I want to use Sitecore security to make access to certain documents on a site require registration/login. However the client would like to show links to these documents to anonymous users as a way to let them know that if they register/login then they will get access to these protected documents.
Is there some simple way to do this in Sitecore? The only thing I can think of off the top of my head is to use some sort of Security Disabler to get the list of documents and display the links on the page.
As Thomas Therkildsen suggests, you can use the Security Disabler, although Sitecore's preferred method is to use a user switcher.
using (new Sitecore.Security.Accounts.UserSwitcher(userWithMoreRights))
{
// ...
}
SecurityDisabler basically gives the code the right to do anything it wants, whereas UserSwitcher is more restrictive.
See the Security API cookbook for more information.
You could use the SecurityDisabler:
using (new SecurityDisabler())
{
//code to get links
}

Set field via URL

Is it possible to have a field in the current item be changed by clicking a URL? The field would be a choice field with predefined choices.
Such as if the item field is currently:
Status: 2
If a user clicks the link, the field would now be:
Status: 3
If not, is there any other way for a user to easily change a field in the current item without actually haveing to visit the item?
Thanks!
Not Out Of The Box (OOTB) - but you've a few options.
Write an ASPX page to do what you want
Use something like SPServices and javascript to update the list item via the web services.
Use the Client Object Model (2010 only)
By the way - changing stuff on a 'get' can be dangerous as you can do malicious things - for example imagine you have a page that deletes the users account without any prompting (exact example doesn't matter) - what if someone clicks on that link by mistake or even worse what about an email sent with an image with that page as source URL - simply viewing the email could delete the users account.
It's not possible by using a GET request, but SharePoint 2010 is offering a RESTful API to manage ListItems from any client
The REST API is located within the virtual WebServices folgder under each SharePoint Site.
http://YourSharePointSite/_vti_bin/ListData.svc.
To perform an update on SharePoint ListItems you have to create a PUT Request. For more information on SharePoints REST API you should have a look at this MSDN site, there are also a lot of samples linked from this article.
Thorsten

WSS site and page permission

I have a simple requirement where a user can input some details using a form.I have created a List and using sharepoint designer generated a customized new entry form which can submit data into list.There are two types of users one end user and second admin.
The problem is ,I have to give permission to the list for end users so that they can fill entry and submit request.This permission allow end end user to jump main site and they able to see list data and other site details.
Is there any way which I can create a group which has only access to that entry (request from) page and not able to browse any other urls
I want to use coding level solution if it is possible with in built functionality.
The new customized form is inbuilt functionality.
Please help .
Thanks
Ritu
you can specific permissions on the list, without giving permissions to the whole site. This way you can even give permissions to only add items. All that could be done using the browser alone

Is it possible to autocomplete fields in Sharepoint with user info?

I'm in charge of a Sharepoint collection, and a user asks this. Is it possible that when a user creates an item, some fields are automatically filled with some info, such as email address and location?
Authentication uses Active Directory, so every user is identified when using Sharepoint. The only issue is that, being in a big corporate company, I don't have any access to the server, so it must be feasible through configuration of said site/list or using Sharepoint Designer, but I can't and won't be allowed to deploy anything server side.
Any idea?
With your limitations, your best bet would be a combination of ajax (I suggest jquery) and sharepoint webservices (if necessary), you need to do a XmlHttpRequest in the userdisp.aspx page, if this page has all the info you need, then get it, otherwise, get the currently logged account and use it to query the webservices (this part I'm not sure if theres a method that will return this info).
This all works using only the browser (Content Editor WebPart) or the SharePoint Designer client.

Sharepoint Redirecting Users or Groups from a page to another

What I am tring to do is, when people comes to that page:
http://server:26521/MY_Portal/service/default.aspx
I want them to be redirected to that page
http://server:26521/default.aspx
Depending on their User name Or User Group.
Thanks for helps.
I can think of two ways to do this:
If you're using ISA Server or a similiar product in front of Sharepoint, you can configure it to do this. So those users who you want redirected will never access the first page.
Alternatively, you could write a webpart, which analyzes who the user is, and does some sort of redirection, either in .net or in javascript to the page you want.

Resources