通过基于声明的NTLM身份验证连接到SharePoint Web服务

时间:2013-04-29 07:10:12

标签: c# web-services sharepoint ntlm claims-based-identity

我们有一个SharePoint服务器,我可以通过以下方式引用它:

//DCP connection
private static dcp.Lists lists = new dcp.Lists();
lists.Credentials = System.Net.CredentialCache.DefaultCredentials;
lists.Url = Values.SERVERADDRESS + "/_vti_bin/lists.asmx";

这适用于仅具有域身份验证(SERVERADDRESShttp://dcp:17649)的端口。 但是,我们的浏览器会在http://https://中使用其他身份验证方法。 这些是基于声明的,包含外部用户的基于表单的身份验证和域上用户的NTLM身份验证。 但是,我似乎无法通过这些端口访问它。 这是我的代码:

//create networkCredential
System.Net.NetworkCredential nc = System.Net.CredentialCache.DefaultNetworkCredentials;
System.Net.CredentialCache cc = new System.Net.CredentialCache();

//add into CredentialCache and speicfy the NTLM authType
cc.Add(new Uri(Values.SERVERADDRESS + "/_vti_bin/lists.asmx"), "NTLM", nc);

lists.Credentials = cc;
lists.Url = Values.SERVERADDRESS + "/_vti_bin/lists.asmx";

此处的SERVERADDRESS值为http://dcp

互联网上有几个帖子(也在这里)与更改app.config有关。但是,我看起来与你在这些帖子中找到的完全不同:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="DriverDevPlanning.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <applicationSettings>
        <DriverDevPlanning.Properties.Settings>
            <setting name="DriverDevPlanning_dcp_Lists" serializeAs="String">
                <value>http://dcp/_vti_bin/Lists.asmx</value>
            </setting>
            <setting name="DriverDevPlanning_dcp_UserGroup_UserGroup" serializeAs="String">
                 <value>http://dcp/_vti_bin/usergroup.asmx</value>
            </setting>
        </DriverDevPlanning.Properties.Settings>
    </applicationSettings>
</configuration>

0 个答案:

没有答案