2

我们有一个 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>
4

0 回答 0