2

对于我们启用 FBA 的 SharePoint 站点之一,我们需要访问各种 Web 服务。我知道在进行任何其他 SP Web 服务调用之前,我们需要调用 Authentication.asmx。

如何获取当前登录用户的用户名和密码以传递给 Authentication.asmx 服务?

谢谢。

更新:我用已知的用户名和密码尝试了 Marek 的解决方案,并得到了 Authentication.asmx 的 401。因此,可能某些设置已关闭。管理员正在调查它。

4

1 回答 1

1
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();
}

但是,根据会员提供商的设置(密码是以明文形式存储、加密还是散列?是否需要通过安全答案才能获取密码?)找回密码可能会更加困难甚至不可能,您需要向用户索取。

于 2011-11-21T08:29:58.277 回答