internal static void LoginAsAdmin([NotNull] Instance instance, [NotNull] Window owner, [CanBeNull] string pageUrl = null, [CanBeNull] string browser = null, [CanBeNull] string[] parameters = null)
        {
            Assert.ArgumentNotNull(instance, "instance");
            Assert.ArgumentNotNull(owner, "owner");

            if (!InstanceHelperEx.PreheatInstance(instance, owner, true))
            {
                return;
            }

            // Generating unique url to authenticate user
            var url          = CoreInstanceAuth.GenerateAuthUrl();
            var destFileName = CoreInstanceAuth.CreateAuthFile(instance, url);

            // Schedule deletion of the file
            var async = new Action(() => DeleteFile(destFileName));

            async.BeginInvoke(null, null);

            var userName   = CoreAppSettings.AppLoginAsAdminUserName.Value;
            var isFrontEnd = false;
            var clipboard  = pageUrl == "$(clipboard)";

            if (clipboard)
            {
                pageUrl = string.Empty;
            }

            if (string.IsNullOrEmpty(pageUrl))
            {
                var value = CoreAppSettings.AppLoginAsAdminPageUrl.Value;
                if (!string.IsNullOrEmpty(value) && !value.EqualsIgnoreCase("/sitecore") && !value.EqualsIgnoreCase("sitecore"))
                {
                    pageUrl = value;
                    if (!value.StartsWith("/sitecore/"))
                    {
                        isFrontEnd = true;
                    }
                }
            }

            var querystring = (string.IsNullOrEmpty(pageUrl) ? string.Empty : "&page=" + pageUrl) + (string.IsNullOrEmpty(userName) || userName.EqualsIgnoreCase("admin") || userName.EqualsIgnoreCase("sitecore\\admin") ? string.Empty : "&user="******"?" + querystring;
            }

            if (clipboard)
            {
                Clipboard.SetDataObject(instance.GetUrl(url + querystring));
            }
            else
            {
                InstanceHelperEx.BrowseInstance(instance, owner, url + querystring, isFrontEnd, browser, parameters);
            }
        }
Exemple #2
0
        protected override void DoExecute(Instance instance, CommandResult <Exception> result)
        {
            Assert.ArgumentNotNull(instance, nameof(instance));
            Assert.ArgumentNotNull(result, nameof(result));

            Ensure.IsTrue(instance.State != InstanceState.Disabled, "instance is disabled");
            Ensure.IsTrue(instance.State != InstanceState.Stopped, "instance is stopped");

            var url          = CoreInstanceAuth.GenerateAuthUrl();
            var destFileName = CoreInstanceAuth.CreateAuthFile(instance, url);

            CoreInstance.Browse(instance, url);
            WaitAndDelete(destFileName);
        }
Exemple #3
0
        protected override void DoExecute(CommandResult <Exception> result)
        {
            Assert.ArgumentNotNull(result, "result");

            var name = this.Name;

            Assert.ArgumentNotNullOrEmpty(name, "name");

            InstanceManager.Initialize();
            var instance = InstanceManager.Instances.FirstOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            Ensure.IsNotNull(instance, "instance is not found");
            Ensure.IsTrue(instance.State != InstanceState.Disabled, "instance is disabled");
            Ensure.IsTrue(instance.State != InstanceState.Stopped, "instance is stopped");

            var url          = CoreInstanceAuth.GenerateAuthUrl();
            var destFileName = CoreInstanceAuth.CreateAuthFile(instance, url);

            CoreInstance.Browse(instance, url);
            WaitAndDelete(destFileName);
        }