Domanda

OK, ecco la mia situazione: Ho un'applicazione di moduli Web ASP.NET che è installata e in esecuzione sul mio sito IIS SP 2013. SP è configurato per utilizzare Windows Auth. So che questo è molto insolito e non raccomandato, ma per ora devo andare in questo modo. I.e. Non ho il tempo di convertire questo e un certo numero di altre app ASP.NET per le app SP. Quello che sto cercando di fare è ottenere l'utente che ha effettuato l'accesso a SP e utilizza questa informazione da autenticare alla mia applicazione ASP.NET - e anche non richiedere AUTH su ASP.NET. Penso per natura dell'App .NET in esecuzione nello stesso IIS AS SP 2013 non richiederà i creditori di autenticazione di Auth un 2a volta., Ma come ottenere informazioni utente dal token?

Ho il codice come

Dim strEmailAddress As String = HttpContext.Current.User.Identity.Name.ToLower
.

Nella mia ASP.NET (VB.NET) e ciò che ritorna è: 0 # .W | SMG \ MyUser

E così come lo capisco SP sta usando l'autenticazione basata sulle rivendicazioni e questo è un rivendicazione Token. La mia domanda è come analizzare / accettare questo token per ottenere il nome utente per poi usarlo nel mio ASP.NET?

Qualcuno altrove sulla rete ha mostrato quanto segue come una soluzione, ma penso che la mia app non possa usare lo spazio dei nomi di Microsoft.SharePoint.Administratore.Claim. È così semplice come quello?

string userName = null;
SPClaimProviderManager mgr = SPClaimProviderManager.Local;
if (mgr != null)
{
    userName = mgr.DecodeClaim(SPContext.Current.Web.CurrentUser.LoginName).Value;
}
.

Come ho capito che SPCLAIMPROVIDERMANAGER è in Microsoft.SharePoint.Administrator.Clamas Space, ma come faccio a fare riferimento nel mio ASP.NET. Non riesco nemmeno a trovare quella DLL sul server SP 2013.

È stato utile?

Soluzione 2

I was able to get this to work using the approach above outlined in my question - i was able to copy Microsoft.Sharepoint assembly from server and reference it in my ASP.NET project. The Microsoft.SharePoint.Administration.Claims namespace is found in the Microsoft.Sharepoint assembly

Altri suggerimenti

The key is to have both SharePoint and your app use the same authentication source.

So, either your app must change to Windows Auth (aka Integrated NTLM), or SharePoint must use forms (or claims that is based on the same user store).

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top