UI suppression - client stuck at SigningIn state

萝らか妹 提交于 2019-12-24 22:22:45

问题


I try to sign in to Skype For Business via my application.

When I'm with UI on, I can sign in.

When I set UI Suppression, my client is stuck at the signing in the state. Neither credentials event nor SigninCallback event nor SignInDelayed event is fired.

Can you help me?

Here is my code:

public void StartUpSkype()
    {

        try
        {

            _LyncClient = LyncClient.GetClient();
            if (_LyncClient == null)
            {
                throw new Exception("Unable to obtain client interface");
            }
            if (_LyncClient.InSuppressedMode == true)
            {
                if (_LyncClient.State == ClientState.Uninitialized)
                {
                    Object[] _asyncState = { _LyncClient };
                    _LyncClient.BeginInitialize(InitializeCallback, _asyncState);
                }
            }
            _LyncClient.SignInDelayed += _LyncClient_SignInDelayed;
            _LyncClient.StateChanged += _Client_ClientStateChanged;
            _LyncClient.CredentialRequested += _LyncClient_CredentialRequested;

        }
        catch (NotStartedByUserException h)
        {
            DisplayErrorMessage("Lync is not running");
        }
        catch (Exception ex)
        {
            DisplayErrorMessage("General Exception");
        }
    }

void _Client_ClientStateChanged(Object source, ClientStateChangedEventArgs data)
    {
        if (data != null)
        {
            if (data.NewState == ClientState.SignedIn)
            {
                DisplayErrorMessage("Signed in");
                UserIsSignedIn?.Invoke(_LyncClient);
            }
            if (data.NewState == ClientState.SignedOut)
            {
                string login = ConfigurationManager.AppSettings["loginSkypeClient"];
                string password = ConfigurationManager.AppSettings["pwdSkypeClient"];

                _LyncClient.SignInConfiguration.ForgetMe(login);

                try
                {
                    // starts the sign in process asynchronously
                    IAsyncResult asyncResult = _LyncClient.BeginSignIn(login, login, password, SigninCallback, _LyncClient);

                    // But wait for the results because the events cannot be registered within a worker thread.
                    asyncResult.AsyncWaitHandle.WaitOne();

                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
    }

    void _LyncClient_CredentialRequested(object sender, CredentialRequestedEventArgs e)
    {
        string login = ConfigurationManager.AppSettings["loginSkypeClient"];
        string password = ConfigurationManager.AppSettings["pwdSkypeClient"];

        if (e.Type == CredentialRequestedType.SignIn)
        {
            e.Submit(login, password, false);
        }
    }

private void SigninCallback(IAsyncResult ar)
    {
        if (ar.IsCompleted == true)
        {
            try
            {
                ((LyncClient)ar.AsyncState).EndSignIn(ar);
            }
            catch (RequestCanceledException re)
            {
                throw re;
            }
        }

    }

private void InitializeCallback(IAsyncResult ar)
    {
        if (ar.IsCompleted == true)
        {
            object[] asyncState = (object[])ar.AsyncState;
            ((LyncClient)asyncState[0]).EndInitialize(ar);

            //_ThisInitializedLync is part of application state and is 
            //a class Boolean field that is set to true if this process
            //initialized Lync.
            _ThisInitializedLync = true;
        }
    }

The login + password are correct because I can sign in with them when the UI is on.

The problem only happens when the UI is suppressed.

I've tried many things, I am desperate right now.


回答1:


Please check the version of SkypeForBusiness. If it is 2016 then it is happening due to ModernAuthentication enabled on both client and tenant office365.

In case ModernAuthentication is enabled, the LyncSDK is not capable enough to handle ModernAuth as SDK doesn't support and Microsoft has no plans to upgrade the SDK.



来源:https://stackoverflow.com/questions/53043790/ui-suppression-client-stuck-at-signingin-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!