3

是否可以在沒有密碼的情況下對MembershipUser進行身份驗證。我有gues用戶帳戶,並有臨時密碼,但我不要求這些用戶實際登錄。我想要自動對其用戶名進行身份驗證。驗證沒有密碼的MembershipUser?

可以這樣做嗎?

FormsAuthentication.SetAuthCookie(publicuser.UserName, false); 

似乎沒有實際驗證他們對memebrship供應商。

+0

爲什麼你需要驗證對用戶會員供應商?爲什麼SetAuthCookie不夠? – jordanbtucker

回答

1

可以覆蓋的ValidateUser在System.ServiceModel.DomainServices.Server.ApplicationServices定義:

protected override bool ValidateUser(string userName, string password) 

然後你就可以檢查

if (IsAGuestAccount(userName)) return true;