protected void Button1_Click(object sender, EventArgs e) { Stopwatch sw = Stopwatch.StartNew(); txtDebug.Text = ""; txtOutput.Text = ""; // configure our SPServiceRequestor. var requestor = new SPServiceRequestor { DobstsEndpoint = txtStarterStsEndpoint.Text, DobstsUsername = txtStarterStsUsername.Text, DobstsPassword = txtStarterStsPassword.Text, DobstsAdfsRealm = txtStarterStsADFSRealm.Text, AdfsEndpoint = txtADFSEndpoint.Text, SharepointRealm = txtSPRealm.Text, SharepointSiteUrl = txtSPSite.Text, IgnoreSslValidation = chkIgnoreSSL.Checked, DebugMode = true, DebugEventCallback = (data) => { _debug(data); } }; string spCookie; // attempt to get a cookie. try { _debug("Requesting SharePoint Cookie..."); spCookie = _cacheService.GetSPCookie(txtStarterStsUsername.Text, txtSPSite.Text, requestor); _debug(String.Format("Got SharePoint Cookie = {0}", spCookie)); } catch (Exception ex) { _debug(String.Format("Exception! {0}", ex.Message)); return; } _debug("Making web service call..."); var error = ""; var groups = getGroupCollection(txtSPSite.Text, spCookie.ToString(), out error); if (error == "") { _debug(String.Format("No errors reported, total groups returned = {0}", groups.Count.ToString())); foreach (DictionaryEntry group in groups) { _output(String.Format("{0}\n", group.Key)); } } else { _debug(String.Format("{0}", error)); } sw.Stop(); _debug(String.Format("Total Execution Time (ms) = {0}", sw.ElapsedMilliseconds)); }
public string GetSPCookie(string username, string spSiteUrl, SPServiceRequestor requestor) { return _inmemorycacheService.Get(_getUserKey(SpCookieHolder, username), () => _spCookie.GetCookie(spSiteUrl, requestor)); }