简体   繁体   English

Sharepoint 使用用户名和密码连接

[英]Sharepoint connection with a username and password

i've searched during 2 days to resolve my problem but there is no way, in fact.我已经搜索了 2 天来解决我的问题,但事实上没有办法。 i'd like to connect to sharepoint using a user's account (there is no probleme when i use anonymous connexion): i added a web reference of authentification and lists to use this code:我想使用用户帐户连接到 sharepoint(我使用匿名连接时没有问题):我添加了 web 认证参考并列出使用此代码:

SPConnect.Authentication authSP = new SPConnect.Authentication();
SPLists.Lists spLists = new SPLists.Lists();
authSP.CookieContainer = new System.Net.CookieContainer();
authSP.AllowAutoRedirect = true;
SPConnect.LoginResult loginSP = authSP.Login("administrateur", "pass");
if (loginSP.ErrorCode == SPConnect.LoginErrorCode.NoError)
   {
       spLists.CookieContainer = authSP.CookieContainer;
       //object list = spLists.GetList("presentationAccueil");
       SPSite oSiteCollection = SPContext.Current.Site;
       SPList listeee = oSiteCollection.AllWebs["http://vmspprod:25401"].Lists["presentationAccueil"];
    }

i get this erro NotInFormsAuthenticationMode when i execute执行时出现此错误 NotInFormsAuthenticationMode

SPConnect.LoginResult loginSP = authSP.Login("administrateur", "pass"); SPConnect.LoginResult loginSP = authSP.Login("administrateur", "pass");

is there any other method to use a user's login and password?还有其他方法可以使用用户的登录名和密码吗?

Thank you in advance for your answers.预先感谢您的回答。

You need to configure your SharePoint server to use Forms Authentication (that's what the exception is telling you).您需要配置您的 SharePoint 服务器以使用 Forms 身份验证(这就是异常告诉您的内容)。

You didn't say which version of SharePoint you are targeting (WSS 3.0, SP 2007, SP 2010).您没有说您针对的是哪个版本的 SharePoint(WSS 3.0、SP 2007、SP 2010)。 Here is a link to an MSDN page that shows you how to configure your server to use Forms Authentication: http://msdn.microsoft.com/en-us/library/bb975136(v=office.12).aspx这是一个指向 MSDN 页面的链接,该页面向您展示如何配置您的服务器以使用 Forms 身份验证: http://msdn.microsoft.com/en-us/library/bb975136(v=office.12).aspx

If you cannot modify the server, then you will need to change your code to use whatever authentication mechanism the server employs.如果您无法修改服务器,那么您将需要更改代码以使用服务器采用的任何身份验证机制。

I hope this helps.我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM