0
votes

Lots of places use sharepoint.

How can we securely retrieve the logged on sharepoint user when they view our app inside a web part?

2
Is your app running in SharePoint, or are you viewing through an IFrame/Page Viewer?kbrimington
Sorry, should say through a Page Viewer/iFrame Unless there is another way to run an external hosted app actually in Sharepoint?Igor K

2 Answers

0
votes

If your WebPart is running in SharePoint you can get the current user from the SPContext.

SPContext.Current.Web.CurrentUser.LoginName

Shane.

0
votes

you need to be in the SharePoint context in order to get the SPUser object in code. Otherwise you could just try

Context.User.Identity.Name

But of course this will not the the AD name and not the SharePoint user.