开发者

Sharepoint connection with a username and password

开发者 https://www.devze.com 2023-03-11 06:08 出处:网络
i\'ve searched during 2 days to resolve my problem but there is no way! in fact, i\'d like to connect to sharepoint using a user\'s account (there is no probleme when i use anonymous connexion).

i've searched during 2 days to resolve my problem but there is no way! in fact, 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:

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

SPCo开发者_高级运维nnect.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).

You didn't say which version of SharePoint you are targeting (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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号