Exemplo n.º 1
0
        /// <summary>
        /// Connect using the parameter set DEVICELOGIN
        /// </summary>
        /// <returns>PnPConnection based on the parameters provided in the parameter set</returns>
        private PnPConnection ConnectDeviceLogin(CancellationToken cancellationToken)
        {
            var           messageWriter = new CmdletMessageWriter(this);
            PnPConnection connection    = null;
            var           uri           = new Uri(Url);

            if ($"https://{uri.Host}".Equals(Url.ToLower()))
            {
                Url += "/";
            }
            var task = Task.Factory.StartNew(() =>
            {
                Uri oldUri = null;

                if (PnPConnection.CurrentConnection != null)
                {
                    if (PnPConnection.CurrentConnection.Url != null)
                    {
                        oldUri = new Uri(PnPConnection.CurrentConnection.Url);
                    }
                }
                if (oldUri != null && oldUri.Host == new Uri(Url).Host&& PnPConnection.CurrentConnection?.ConnectionMethod == ConnectionMethod.DeviceLogin)
                {
                    ReuseAuthenticationManager();
                }

                var returnedConnection = PnPConnectionHelper.InstantiateDeviceLoginConnection(Url, LaunchBrowser, messageWriter, AzureEnvironment, cancellationToken);
                connection             = returnedConnection;
                messageWriter.Finished = true;
            }, cancellationToken);

            messageWriter.Start();
            return(connection);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Connect using the parameter set SPOMANAGEMENT
        /// </summary>
        /// <returns>PnPConnection based on the parameters provided in the parameter set</returns>
        //private PnPConnection ConnectSpoManagement()
        //{
        //    return ConnectNativeAAD(SPOManagementClientId, SPOManagementRedirectUri);
        //}

        /// <summary>
        /// Connect using the parameter set DEVICELOGIN
        /// </summary>
        /// <returns>PnPConnection based on the parameters provided in the parameter set</returns>
        private PnPConnection ConnectDeviceLogin()
        {
            bool ctrlCAsInput = false;

            if (Host.Name == "ConsoleHost")
            {
                ctrlCAsInput = Console.TreatControlCAsInput;
                Console.TreatControlCAsInput = true;
            }

            var uri = new Uri(Url);

            if ($"https://{uri.Host}".Equals(Url.ToLower()))
            {
                Url += "/";
            }
            var connection = PnPConnectionHelper.InstantiateDeviceLoginConnection(Url, LaunchBrowser, TenantAdminUrl, Host, NoTelemetry, AzureEnvironment);

            if (Host.Name == "ConsoleHost")
            {
                Console.TreatControlCAsInput = ctrlCAsInput;
            }
            return(connection);
        }