SharePoint 2013 get current user using JavaScript

Here is the code that worked for me: <script src=”https://stackoverflow.com/SiteAssets/jquery.SPServices-2013.02a.js” type=”text/javascript”></script> <script src=”/SiteAssets/jquery.js” type=”text/javascript”></script> <script type=”text/javascript”> var userid= _spPageContextInfo.userId; var requestUri = _spPageContextInfo.webAbsoluteUrl + “/_api/web/getuserbyid(” + userid + “)”; var requestHeaders = { “accept” : “application/json;odata=verbose” }; $.ajax({ url : requestUri, contentType : “application/json;odata=verbose”, headers : requestHeaders, success : onSuccess, error : onError }); function … Read more

Upload a file to SharePoint through the built-in web services

Example of using the WSS “Copy” Web service to upload a document to a library… public static void UploadFile2007(string destinationUrl, byte[] fileData) { // List of desination Urls, Just one in this example. string[] destinationUrls = { Uri.EscapeUriString(destinationUrl) }; // Empty Field Information. This can be populated but not for this example. SharePoint2007CopyService.FieldInformation information = … Read more

“Object doesn’t support this property or method” error in IE11

This unfortunately breaks other things. Here is the fix I found on another site that seemed to work for me: I’d say leave the X-UA-Compatible as “IE=8″ and add the following code to the bottom of your master page: <script language=”javascript”> /* IE11 Fix for SP2010 */ if (typeof(UserAgentInfo) != ‘undefined’ && !window.addEventListener) { UserAgentInfo.strBrowser=1; … Read more

SharePoint Rest API how to get Access Token?

To call SharePoint specific APIs you need to get a SPO specific access token. You can “swap” an regular MS Graph refresh token for an SPO specific token by doing the following: Get a delegated auth token from graph as you normally would (https://learn.microsoft.com/en-us/graph/auth-v2-user) Use the refresh_token you got and exchange it for an SPO … Read more

How do I perform WIF/claims impersonation without the claim being mapped to an AD account?

I spent several months working on trying to solve this problem and after spending a long time working with Microsoft SharePoint and WIF engineers came to the conclusion that this is not possible. It appears that the issue is basically what Kirk alludes to. When creating an impersonated session using Claims (e.g. creating an SPClaim … Read more