Export (0) Print
Expand All

Signing In to Communicator Web Access Server

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

When the sign-in channel is properly implemented, signing in to Communicator Web Access Server is simple:

  1. Create the logon request to go as the message body.

  2. Select a URL of a server handler for signing in using form-based authentication or integrated Windows authentication.

  3. Send the request through the sign-in channel.

If the logon is successful, the authentication ticket is filled. If logon fails, the authentication ticket is null. The example code verifies the logon in this way. The authentication ticket is periodically updated by the Communicator Web Access Server. To ensure that the client is caching the current authentication ticket, the client should retrieve the CWA-Ticket from the header section of the HTTP response object received on the data channel.

When a user is signed in, the user has been authenticated by the Communicator Web Access Server and is now permitted to initiate a session, call the methods, and retrieve the events.

The following C# snippet provides such an example. Note that this is the initial cwaRequests element containing only the logon element. As such, it does not need the xmlns="http://schemas.microsoft.com/2006/09/rtc/cwa" attribute/value pair. All subsequent cwaRequest elements require the attribute/value pair.

public bool logon(string domain, string user, string password,
                   string uri)
{
   string strRequest =
                "<cwaRequests>" +
                "   <logon>" +
                "      <user>" + domain + "\\" + userId + "</user>" +
                "      <password>" + password + "</password>" +
                "      <uri>" + uri + "</uri>" +
                "   </logon>" +
                "</cwaRequests>";
   xmlDocument xmlRequest = new XmlDocument();
   xmlRequest.LoadXml(strRequest);
   sendRequest("https://www.contoso.com/forms/logon.html;",
                   xmlRequest);

   return this.authTicket != null;
}
…
void ProcessAuthTicket(WebHeaderCollection headers)
{
   string ticket = headers["CWA-Ticket];
   if (ticket != null && ticket != string.Empty)
   this.authTicket = ticket;
}

An implementation of the SendRequest is shown in the Setting Up Sign-in and Command Channels topic.

The following JavaScript code snippet uses an XMLHttpRequest object to post a sign-in request. The request is made as a synchronous HTTP POST.

// For Internet Explorer version 6.0 and earlier:
var req = new ActiveXObject('Microsoft.XMLHTTP');

// For Safari:
req = new XMLHttpRequest();
......
var user="john";
var domain = "contoso.com";
var password = "...";
var authTicket = "";   // To start with an empty ticket
var isAuthenticated = false;

DoLoginForms(user, domain, password );
......

function DoLoginForms(user, domain, passWord )
{
    var requestBody = "<cwaRequests>" + "<logon">"
                    + "<user>" + domain + "\\" + user + "</user>"
                    + "<password>" + password + "</password>"
                    + "</logon></cwaRequests>";

    var url = "https://cwa.contoso.com/forms/logon.html";
    req.open("POST", url, false);
    req.send(requestBody);

    authTicket = req.getResponseHeader("CWA-Ticket");
    if(req.readyState == 4 && req.status == 200 && authTicket != "")
    {
        isAuthenticated = true;
    }

}
Show:
© 2015 Microsoft