I am currently developing a program that will upload selected files to a specific folder (and create the folders automatically if necessary) on SharePoint and give access to specific users based on their emails using SharePoint CSOM, however I am unable to retrieve the links for people outside of my domain.
For example, with my current code, I am retrieving links like the following:
https://domain.sharepoint.com/:f:/r/sites/TestSite/Shared%20Documents/2019/11157/Test%20Upload?csf=1
However, the link I am trying to retrieve is like the following:
https://domain.sharepoint.com/:f:/s/TestSite/EmUDng-KzwxEtHKyJ9Okl0MBlS_z8gxGFl4UUjuGXHmR9w
I can retrieve the link above if I go into SharePoint and manually retrieve it (the program makes the links correctly), but that defeats the purpose of my program. The program is supposed to automate the upload and link retrieval of files from within my company's domain.
I do not want the first link because only people who are within my domain can access the file/folder with it. The 2nd link allows for anyone who has been given access (via an email address) to access the file/folder.
I am currently retrieving the first link by using the code from here: https://www.c-sharpcorner.com/article/generating-sharing-links-report-and-removing-sharing-links-using-sharepoint-onli/
I have also tried other suggestions I have found on StackExchange such as: https://sharepoint.stackexchange.com/questions/91451/manage-links-for-shared-files
All examples I have found like the above all result in the incorrect links.
In case it is not clear currently, I am not after an anonymous link or how to create shared links (as I already have this working), I am after the link that would appear here
I managed to find the solution after just randomly trying everything. What you can do is as follows:
First, create the sharing link in the way I was previously:
SharingResult result = context.Web.ShareDocument(site,
email,
ExternalSharingDocumentOption.View,
false,
"Document Shared as test");
Then with the result variable, grab the invitation link of one of the invited users and then modify it to work for any user (as it turns out, specific links are the same for all users other than a parameter on the end)
string link = result.InvitedUsers.FirstOrDefault().
int index = link.IndexOf("?");
if (index > 0) link = link.Substring(0, index);
This results in the correct link I was looking for. I did speak to some people from Microsoft asking about this, so, thanks Microsoft for telling me this was impossible!
Related
I want to build a media library system but don't know how to go about securing my files from anybody body who want to hack my system. I don't want any user to use one particular link to access my files, I want only user who can buy the media to have access to a particular file. if one "friend" access it, and then give the file URL to unauthorized person the friend should not be able to access it.
for example, if I have the following link, how do I go about make another person not to have access to it.
https://a4.sphotos.ak.fbcdn.net/hphotos-ak-ash4/296040_2530953916384_1329592446_32898884_1499197273_n.jpg
I will like know how I can go about implementing this in Asp.Net MVC.
Follow the Following [LINK] (http://www.wrox.com/WileyCDA/Section/id-291916.html) to do that. Im Sured it Helps.
What I need to do is quite simple although is causing me lots of trouble.
I need to create programmatically an AssetUrlSelector in a web part that selects a file in sharepoint 2010 and makes its path available to be used elsewhere.
So far I have managed to create the AssetUrlSelector and display the path on a textbox, however I cannot use this as every reference to it will be null.
Have you got any practical example?
Try the Document ID Service. In short this service generates IDs for documents (files) and generates an url with this ID so even if the file is moved the url stays valid and the service returns the document. This service might rely on search functionality unless you implement your custom search. Here is an article on how to configure OOB Doc IDs here. Also you can google further if you're interested.
is it possible in Sharepoint 2010 set a permission on a document in order to allow a specific user to view this document (when viewing the documents of a specific document library for example) without giving him the privilege to open it?
For example, [user1] can see that in the list of documents of document library [DocLib1] there is a document called [doc1.docx], but [user1] doesn't have the permission to open[doc1.docx] and view its content.
Technically raymund's answer is obscurity instead of security. If you are going to go that route you can simply update your primary view to remove any links to the document. and create a seperate view for those authorized.
Edit***
after double checking msdn, I found the user permissions article. This shows that there are in deed two seperate permission levels - view items and open items. unfortunately view items is dependent upon the open items permission level, therefore unable to really accomplish your goal.
http://technet.microsoft.com/en-us/library/cc288074.aspx
You can do this by creating a SOAP Service Connection in Sharepoint Designer
Then using your Document List as the source (declaring a login on the login tab with a privilage to tread the list) , then displaying it as a dataview in a sharpoint form.
I have a similar sample here which has a better explanation using a list instead (I should work the same with document library as they are exposed both as lists).
I am trying to make a web part that will display what links got clicked/viewed the most across the whole site collection. These links come from a SharePoint list.
Is there a mechanism in the object model that can be used to accomplish this?
Any thought would be helpful.
If the links all go to SharePoint pages within your portal, then you might be able to gather the information in your Site Usage Report, then query that in a custom web part. If the links point to places outside your portal, I am not aware of any out-of-the-box record of which links are getting clicked on in a SharePoint list. You could possibly make some javascript to add special code to the list interface so that, whenever a link is clicked, it first records to a database, then takes the user to the destination.
After much wrangling I have a development environment for building sharepoint webparts in c#.
I'm completely new to SP development, so I haven't quite found the various API docs, so I'm hoping someone can help get me started.
Eventually, I want to write a simple web part that allows its user to display different content depending on who the current user is.
What I'd like to do first though is just build a dead simple webpart that will simply print out the current user's details - username, full name and any permissions groups that they have.
Thanks
SPContext.Current.Web.CurrentUser