How to secure a file from anonymous and authenticated user in C# - c#

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.

Related

Get users full name from their Facebook link

I've been looking around for a way to get someone's full name (as displayed on their facebook account) by following a link.
For instance, if you were to type https://www.facebook.com/zuck in your browser, everyone would be able to see that his name is Mark Zuckerberg. I want to get this information from a C# application, based on a direct URL.
As far as I've understood by reading around, scraping is not allowed on facebook, so that's not an option. Another thing I've looked into is Facebooks Graph API, however it seems that it's not possible to get someone elses name using that api, you can only get your own name using your own access token. I can't really seem to understand whether or not this is possible/legal to even do this. Does anyone have any insight on this?

How to retrieve SharePoint Share Links using CSOM

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!

Microsoft Graph Schema Registration

I am working on creating a simple calendar app to track the user's Outlook.com calendar. In order to add some custom information I am needing to use Schema Extension as this information must be filterable and to my knowledge there is no filterable on Open Extension data.
I have followed the RegisterSchemaExtension() from the following sample: https://github.com/microsoftgraph/uwp-csharp-snippets-rest-sample/blob/master/O365-UWP-Unified-API-Snippets/Extensions/ExtensionSnippets.cs
and have added the proper scope to my application. I have also added the Directory.AccessAsUser.All permission to my app through the app registration portal at: https://apps.dev.microsoft.com/portal/register-app
Despite this, I am unable to register the schema and get error saying: MethodNotAllowed. I am not sure where to go from here as I haven't been able to find useful resources on the web. Apologies for the English! It is not perfect yet but I am learning!
With how complicated the Schema Extension turned out I decided to use Open Extension and do filtering manually.

Upload from C# to GDrive

Please help. I am looking for a way to upload a file to Google Drive with my app. The Google Account in question will be a specific one, i.e. not the client's account, a 'Service' account. I've tried to Google it, but I can't find anything that seems to do what I want, And the API reference I probably don't understand. I have been thrown in the deep end for a project. Any source or links to help Please! I am not asking anyone to write my source, but if it exists, it would be nice.
Note: This is my last hope. I don't ask a question unless there is nooooo other way.
(I am using Windows Forms)
Thanks
Jacques
EDIT: It is always signing in to MY drive, whether I am using it or you are using it. I have also posted this question to CodeProject to harness maximum brain power.
PermaLink: http://www.codeproject.com/Questions/652006/Upload-from-Csharp-to-GDrive
This page tells you what you need to know about authorizing a service account https://developers.google.com/drive/service-accounts
This page shows you the C# required to upload a file, once you have been authorized https://developers.google.com/drive/v2/reference/files/insert
Treat the authorization and the uploading as two separate problems and you'll find life much easier. The end result of the authorization procedure is an access token. Give that access token the insert API and you're all set.

Set Default Directory for Lotus Notes File Upload Control

I have a lotus notes web form in which computer-illiterate customers will use to attach Excel files and submit them to our company. I am using a Lotus Notes File Upload Control to allow them to do this, however, I need to default this File Upload Control to a certain directory location. I have already created a C# application the customers will be using, which places all of these excel files in a certain directory location, hence the reason I need to focus this File Upload Control. Unfortunately, some of the customers are computer challenged enough to not know how to navigate to these files on their own. Is this possible at all?
I'm assuming the users will be visiting a web page with the File Upload control, yes? If I'm misunderstanding please let me know and I'll delete this answer.
The simple answer is it isn't possible. The problem is that the browser can't know anything about the file structure of the clients that visit the site, so a "default path" property doesn't really make sense. It would likely only work in very specific environments (which is maybe true in your case, but not across the web in general)
I would investigate using the Notes API to have the C# program handle the upload without involving the browser client use of the file upload control. I don't know enough Java to be sure, but perhaps that might also be an option -- basically writing your own custom upload control that only asks the user for the filename.
You may also be seriously underestimating the ability of the users to follow directions. If your page identifies which directory the file will be found in, I expect most users will be able to follow the directions and upload from the correct directory.
So, I'm sure that accomplishing what you want to accomplish is possible in Notes, just not as simply as adding a default directory to the File Upload Control.

Categories