SharePoint2010用のasp.netアプリケーションを開発しています。asp.netアプリケーションでSharePointデータにアクセスしたいと思います。したがって、私はWebサービスを使用しています。WebサービスのURLは。で始まりhttps
ます。次のコードを使用してWebサービスにアクセスしています。
private void TryOutCode()
{
//SharepointWebApplication.ListsServiceReference.ListsSoap s;
SharepointWebApplication.ServiceReference1.ListsSoapClient proxy = new SharepointWebApplication.ServiceReference1.ListsSoapClient();
proxy.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
//proxy.ClientCredentials.Windows.ClientCredential.UserName = @"anil-pc\owner";
//proxy.ClientCredentials.Windows.ClientCredential.Password = "123";
//proxy.ClientCredentials.Windows.AllowNtlm = true;
//proxy.ClientCredentials.Windows.ClientCredential = new NetworkCredential("owner", "123", "anil-pc");
proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
//Microsoft.SharePoint.SPListItem li = new Microsoft.SharePoint.SPListItem();
//Define the parameters for the service call
XElement query = new XElement("Query");
XElement queryOptions = new XElement("QueryOptions");
XElement viewFields = new XElement("ViewFields");
XElement result = proxy.GetListItems("PBS Internal Contacts", null, query, viewFields, null, queryOptions, null);
//XDocument list_data = XDocument.Parse(result);
XNamespace ns = "#RowsetSchema";
var query1 = from x in result.Descendants()
where x.Name == ns + "row"
select new PBSInternalContacts
{
User = x.Attribute("ows_User").Value,
Role = x.Attribute("ows_Role").Value,
};
List<PBSInternalContacts> pbsInternalContactsList = query1.ToList();
GridView1.DataSource = pbsInternalContactsList;
GridView1.DataBind();
}
私のweb.configファイルは次のとおりです
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ListsSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="ListsSoap1" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="ListsSoap2" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/_vti_bin/Lists.asmx" binding="basicHttpBinding"
bindingConfiguration="ListsSoap" contract="ListsServiceReference.ListsSoap"
name="ListsSoap" />
<endpoint address="https://abc.info/_vti_bin/Lists.asmx"
binding="basicHttpBinding" bindingConfiguration="ListsSoap1"
contract="ServiceReference1.ListsSoap" name="ListsSoap1" />
</client>
</system.serviceModel>
</configuration>
上記のコードでデバッグすると、エラーが発生します'HTTPリクエストはクライアント認証スキーム'Ntlm'で許可されていません。サーバーから受信した認証ヘッダーは「NTLM」でした。次の行でエラーが発生します
XElement result = proxy.GetListItems("PBS Internal Contacts", null, query, viewFields, null, queryOptions, null);
ユーザー名とパスワードを使用してSharePointWebサービスにアクセスするにはどうすればよいですか。上記の問題を解決するためのコードまたはリンクを教えてください。