Quantcast
Channel: Microsoft Unified Communications Managed API SDK forum
Viewing all articles
Browse latest Browse all 889

Lync authentication using current users credentials

$
0
0

I need to create a conference on behalf of the currently logged in user from a SharePoint page.

If i provide the credentials for the UserEndpoint like this:
userEndpoint.Credential = new System.Net.NetworkCredential(settings.CredentialsName, settings.CredentialsPassword, settings.CredentialsDomain);
Then it works ok, the conference is created.

But i don't want the user to provide the credentials, so i try this:
userEndpoint.Credential = CredentialCache.DefaultNetworkCredentials;
Now this obviously doesn't work because WindowsIdentity.GetCurrent() is "NT Authority\IUSR".
The SharePoint site is using claims authentication.

So then i try to get the windowsidentity using the claims to windows token service:
IClaimsIdentity identity = (ClaimsIdentity)Thread.CurrentPrincipal.Identity;
--snip
WindowsIdentity windowsIdentity = S4UClient.UpnLogon(upn);

Then i try to execute all the lync code in a windows impersonation context.
Now the impersonation context works, WindowsIdentity.GetCurrent() is switching from "NT Authority\IUSR" to the current user.
But still i get "Unable to perform authentication of credentials".

Ok then i try to use the LogonUser API, just for testing impersonation:
NativeMethods.LogonUser(userName,  domain, password, NativeMethods.LOGON32_LOGON_INTERACTIVE, NativeMethods.LOGON32_PROVIDER_DEFAULT, ref token)
--snip
WindowsIdentity tempWindowsIdentity = new WindowsIdentity(tokenDuplicate)
And then runn all the lync code in a windows impersonation context.
But still getting the "Unable to perform authentication of credentials" ?

If i provide the users credentials in the userendpoint, it always works. With or without impersonation.

Anyway, i'm a bit lost on how i can achieve this.
If anyone has any tips at all, please let me know.

Simplified code:

            _credential = CredentialCache.DefaultNetworkCredentials;
            if (!settings.UseCurrentUsersCredentials)
            {
                _credential = new System.Net.NetworkCredential(settings.CredentialsName, settings.CredentialsPassword, settings.CredentialsDomain);
            }

            ClientPlatformSettings clientPlatformSettings = new ClientPlatformSettings(settings.ApplicationUserAgent, SipTransportType.Tls);
            _collaborationPlatform = new CollaborationPlatform(clientPlatformSettings);

            UserEndpointSettings userEndpointSettings = new UserEndpointSettings(settings.UserEndPointSip, settings.LyncServer);
            userEndpointSettings.Credential = _credential;

            _currentEndpoint = new UserEndpoint(_collaborationPlatform, userEndpointSettings);

            _currentEndpoint.Platform.BeginStartup(EndPlatformStartup, _currentEndpoint.Platform);

            _currentEndpoint.BeginEstablish(EndEndpointEstablish, _currentEndpoint);

 


Viewing all articles
Browse latest Browse all 889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>