Home
Manage Your Code
Snippet: sharepoint web service in forms authentication (C#)
Title: sharepoint web service in forms authentication Language: C#
Description: This example shows how to initialize a web service when using forms authentication Views: 675
Author: tom hollander Date Added: 11/23/2007
Copy Code  
1protected UserGroup ws_UserGroup
2        { 
3            get
4            {                
5                if (m_wsGroup == null)
6                {
7                    Authentication auth = new Authentication();
8                    auth.CookieContainer = new CookieContainer();
9                    LoginResult result = auth.Login("username", "password");
10                    if (result.ErrorCode == LoginErrorCode.NoError)
11                    {
12                        CookieCollection cookies = auth.CookieContainer.GetCookies(new Uri(auth.Url));
13                        Cookie authCookie = cookies[result.CookieName];
14
15                        m_wsGroup = new UserGroup();
16                        m_wsGroup.CookieContainer = new CookieContainer();
17                        m_wsGroup.CookieContainer.Add(authCookie);
18                        m_wsGroup.Url = ConfigurationManager.AppSettings["ws_Group_URL"];                      
19                    }
20                }
21                return m_wsGroup;
22            }
23        }