从哪里获取用于 Authentication.asmx 的凭据?

发布于 2024-12-17 12:54:06 字数 269 浏览 0 评论 0原文

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

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

谢谢。

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

For one of our FBA enabled SharePoint site, we need to access various web services. I know that we need to invoke Authentication.asmx before we make any other SP web service call.

How do I get the currently logged in user's username & password to pass to the Authentication.asmx service?

Thanks.

Update: I tried Marek's solution with a known username and password and got a 401 for Authentication.asmx. So probably some settings are off. The admin is looking into it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

客…行舟 2024-12-24 12:54:06
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();
}

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

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

However, depending on the settings of the membership provider (is password stored in plain text, encrypted or hashed? is it required to pass the security answer to get the password?) retrieving the password may be more difficult or even impossible and you will need to ask the user for it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文