private void ConnectUmbraco6x(TreeView treeView, string sServerUrl, string sSiteType) { LoginForm login = new LoginForm(); login.SiteUrl = sServerUrl; login.SiteType = sSiteType; login.Username = "******"; if (login.ShowDialog(this) == DialogResult.Cancel) return; Credentials credentials = new Credentials(); credentials.UserName = login.loginControl1.Username; credentials.Password = login.loginControl1.Password; Umbraco6xItem item = null; try { Umbraco6xAPI umbracoAPI = new Umbraco6xAPI(sServerUrl, credentials); item = Umbraco6xItem.GetRoot(umbracoAPI, new ConverterOptions()); } catch (Exception ex) { MessageBox.Show("Error logging into site, wrong username or password?\nError message: " + ex.Message); return; } item.Options.LoginName = credentials.UserName; item.Options.LoginPassword = credentials.Password; item.Options.HostName = sServerUrl; treeView.Nodes.Clear(); TreeNode newNode = new TreeNode(item.Name); newNode.Tag = item; treeView.Nodes.Add(newNode); treeView.SelectedNode = newNode; }
private void ConnectSitecore5x(TreeView treeView, string sServerUrl, string sSiteType) { CMSConverter.Core.Sitecore5x.VisualSitecoreService sitecoreApi = new CMSConverter.Core.Sitecore5x.VisualSitecoreService(); sitecoreApi.Url = sServerUrl + "/sitecore/shell/webservice/service.asmx"; sitecoreApi.Credentials = CredentialCache.DefaultCredentials; //new System.Net.NetworkCredential(); CMSConverter.Core.Sitecore5x.Credentials credential = new CMSConverter.Core.Sitecore5x.Credentials(); sitecoreApi.CookieContainer = new CookieContainer(); sitecoreApi.UnsafeAuthenticatedConnectionSharing = true; // Timeout = 30 seconds (default 10) sitecoreApi.Timeout = 300000; LoginForm login = new LoginForm(); login.SiteUrl = sServerUrl; login.SiteType = sSiteType; login.Username = "******"; if (login.ShowDialog(this) == DialogResult.Cancel) return; credential.UserName = login.loginControl1.Username; credential.Password = login.loginControl1.Password; Sitecore5xItem item = null; try { item = Sitecore5xItem.GetItem("/sitecore", sitecoreApi, credential); } catch (Exception ex) { MessageBox.Show("Error logging into site, wrong username or password?\nError message: " + ex.Message); return; } item.Options.LoginName = credential.UserName; item.Options.LoginPassword = credential.Password; item.Options.HostName = sServerUrl; treeView.Nodes.Clear(); TreeNode newNode = new TreeNode(item.Name); newNode.Tag = item; treeView.Nodes.Add(newNode); treeView.SelectedNode = newNode; }
private void ConnectSitecore61(TreeView treeView, string sServerUrl, string sSiteType) { CMSConverter.Core.Sitecore61.VisualSitecoreService sitecoreApi = new CMSConverter.Core.Sitecore61.VisualSitecoreService(); sitecoreApi.Url = sServerUrl + "/sitecore/shell/webservice/service.asmx"; sitecoreApi.Credentials = CredentialCache.DefaultCredentials; //new System.Net.NetworkCredential(); CMSConverter.Core.Sitecore61.Credentials credential = new CMSConverter.Core.Sitecore61.Credentials(); sitecoreApi.CookieContainer = new CookieContainer(); sitecoreApi.UnsafeAuthenticatedConnectionSharing = true; // Timeout = 30 seconds (default 10) sitecoreApi.Timeout = 300000; try { sitecoreApi.VerifyCredentials(credential); } catch (System.Net.WebException ex) { if ((ex.Status == System.Net.WebExceptionStatus.ProtocolError) && (ex.Message.IndexOf("401: Unauthorized") > -1)) { LoginForm BasicAuthLogin = new LoginForm(); BasicAuthLogin.SiteUrl = sServerUrl + "/Basic authentication"; BasicAuthLogin.SiteType = "Basic authentication"; BasicAuthLogin.Username = ""; BasicAuthLogin.Password = ""; if (BasicAuthLogin.ShowDialog(this) == DialogResult.Cancel) return; CredentialCache credCache = new CredentialCache(); NetworkCredential netCred = new NetworkCredential(BasicAuthLogin.Username, BasicAuthLogin.Password); credCache.Add(new Uri(sitecoreApi.Url), "Basic", netCred); sitecoreApi.Credentials = credCache; sitecoreApi.PreAuthenticate = true; } } LoginForm login = new LoginForm(); login.SiteUrl = sServerUrl; login.SiteType = sSiteType; login.Username = "******"; if (login.ShowDialog(this) == DialogResult.Cancel) return; credential.UserName = "******" + login.loginControl1.Username; credential.Password = login.loginControl1.Password; Sitecore6xItem item = null; try { item = Sitecore6xItem.GetItem("/sitecore", sitecoreApi, credential, new ConverterOptions()); } catch (Exception ex) { MessageBox.Show("Error logging into site, wrong username or password?\nError message: " + ex.Message); return; } item.Options.LoginName = credential.UserName; item.Options.LoginPassword = credential.Password; item.Options.HostName = sServerUrl; treeView.Nodes.Clear(); TreeNode newNode = new TreeNode(item.Name); newNode.Tag = item; treeView.Nodes.Add(newNode); treeView.SelectedNode = newNode; }
private void ConnectSitecore43(TreeView treeView, string sServerUrl, string sSiteType) { CMSConverter.Core.Sitecore43.SitecoreClientAPI sitecoreApi = new CMSConverter.Core.Sitecore43.SitecoreClientAPI(); sitecoreApi.Url = sServerUrl + "/sitecore/client/api/api.asmx"; sitecoreApi.Credentials = CredentialCache.DefaultCredentials; //new System.Net.NetworkCredential(); sitecoreApi.CookieContainer = new CookieContainer(); sitecoreApi.UnsafeAuthenticatedConnectionSharing = true; sitecoreApi.Timeout = 120 * 1000; string sLoginName = null; string sLoginPassword = null; if (!sitecoreApi.IsLoggedIn()) { LoginForm login = new LoginForm(); login.SiteUrl = sServerUrl; login.SiteType = sSiteType; login.Username = "******"; if (login.ShowDialog(this) == DialogResult.Cancel) return; try { sitecoreApi.Login(login.loginControl1.Username, login.loginControl1.Password); sLoginName = login.loginControl1.Username; sLoginPassword = login.loginControl1.Password; } catch { MessageBox.Show("Error logging into site, wrong username or password?"); return; } } Sitecore43Item item = Sitecore43Item.GetItem("/sitecore", sitecoreApi); item.Options.LoginName = sLoginName; item.Options.LoginPassword = sLoginPassword; item.Options.HostName = sServerUrl; treeView.Nodes.Clear(); TreeNode newNode = new TreeNode(item.Name); newNode.Tag = item; treeView.Nodes.Add(newNode); treeView.SelectedNode = newNode; }