获取指定用户的凭证

发布于 2024-10-18 11:00:33 字数 141 浏览 1 评论 0原文

我写了一个Windows服务。该服务必须连接 SharePoint 服务并获取每个用户不同的数据。 sharePoint 服务根据调用服务之前设置的用户凭据返回数据。

如果服务可以在任何需要获取此凭据的帐户下运行,我如何通过用户名和用户域获取用户凭据?

I wrtitting a windows service. This service has to connect SharePoint service and get data different for each user. sharePoint service return data based on user credentials whitch are set before calling service.

How can I get user credentials by user name and user domain if the service can be run under any account that needs to get this credentials?

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

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

发布评论

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

评论(1

瀞厅☆埖开 2024-10-25 11:00:33

根据您添加共享点服务的方式(Web 引用或服务引用),可以使用不同的方法来随请求发送凭据。

使用 Web 引用,您可以添加一个 NetworkCredentials 对象,其方式如下:

SomerService ws = ... //instantiate your service
ws.PreAuthenticate = true;
ws.Credentials = new System.Net.NetworkCredentials("username","pw","domain");

如果它是带有 wsHttpBinding 的服务引用,则如下所示:

Service client = ... //instantiate your service
client.ClientCredentials.UserName.UserName = "domain\\username";
client.ClientCredentials.UserName.Password = "password";

那么您需要存储用户名/您为其检索内容的每个用户的密码。

如果这是一个直通服务,其中客户端访问您的服务并代表用户访问共享点,您必须设置 Kerberos 身份验证并允许模拟通过。也许你可以扩展你想要完成的事情。

Depending on how you add the sharepoint service (web reference or service reference) there are different methods to send credentials with the request.

With a web reference you would add a NetworkCredentials object along the lines of:

SomerService ws = ... //instantiate your service
ws.PreAuthenticate = true;
ws.Credentials = new System.Net.NetworkCredentials("username","pw","domain");

if it´s a service reference with wsHttpBinding then something like this:

Service client = ... //instantiate your service
client.ClientCredentials.UserName.UserName = "domain\\username";
client.ClientCredentials.UserName.Password = "password";

Then you need to store the username/password for each user you are retrieving content for.

If this is a pass-thru service where the client accesses your service and it access sharepoint on the users behalf you have to set up Kerberos authentication and allow impersonation to pass thru. Maybe you could expand on what you are trying to accomplish.

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