MembershipUser user = Membership.GetUser();
string username = user.UserName;
string password = user.GetPassword();
Authentication auth = new Authentication();
auth.CookieContainer = new CookieContainer();
LoginResult result = auth.Login(username, password);
if (result.ErrorCode == LoginErrorCode.NoError)
{
CookieCollection cookies = auth.CookieContainer.GetCookies(new Uri(auth.Url));
Cookie authCookie = cookies[result.CookieName];
Lists lists = new Lists();
lists.CookieContainer = new CookieContainer();
lists.CookieContainer.Add(authCookie);
lists.GetListCollection();
}
但是,根据会员提供的设置(存储的密码以纯文本,加密或散列?是通过安全的答案得到密码?它需要)取回密码可能会更加困难甚至不可能,您需要向用户询问。
谢谢Marek。我们需要从许多自定义aspx页面访问Web服务。 – noobDotNet
PasswordFormat是“哈希”,并且在web.config中将EnablePasswordRetrieval设置为false。有没有解决的办法?谢谢。 – noobDotNet
@noobDotNet从安全的角度来看,对密码进行散列是最好的选择,但这也意味着您将无法从数据库中检索它们。“您可以使用单个专用帐户来进行所有Web服务调用? –