[英]Retrieving information of validated user in WCF
我在http://www.codeproject.com/Articles/380900/WCF-Authentication-and-Authorization-in-Enterprise中關注此教程
現在,我已經登錄並進行了所有操作,實際上沒有問題,它可以正常運行。 我什至還使用MD5哈希添加了一些加密技術。 但是我不確定如何獲取用戶信息。 因此,當他們調用實用程序服務時,我將如何查詢該特定用戶的數據庫?
[PrincipalPermission(SecurityAction.Demand, Role = "Read")]
public Data.UserProfiles ViewProfile()
{
using (var context = new DatabaseEntities())
{
var user = context.UserProfiles.SingleOrDefault(u => u.UserName == ???)
return user;
}
}
如果在Web應用程序中使用WCF,則可以像CodeProject文章一樣將用戶詳細信息存儲在cookie中,或者可以按照以下方法進行WCF身份驗證:msdn.microsoft.com/zh-cn/library/ff405740.aspx
使用以下代碼獲取用戶:var currentUser = new WindowsPrincipal((WindowsIdentity)System.Threading.Thread.CurrentPrincipal.Identity);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.