User Tools

Site Tools


developers:examples:c-sharp:basic

This is an old revision of the document!


ADUCID - using C# and ASP.NET - Basic authentication example

See all C# Examples

Get sources and binaries on GitHub

Simplified authentication request with personal factor verification written in C#

Import WSDL into your project in Visual Studio.

Create an instance of AducidApiServiceClient and make calls to ADUCID and get authentication result with a few rows of code:

I. Start page

This page starts authentication request. As a parameter of verifyLF method we provide URL with final page where authentication is evaluated:

protected void Page_Load(object sender, EventArgs e) {
            var aducid = new AducidApiServiceClient();
            string host = "http://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port;
            var redirect = aducid.startAuthenticationSession(host + "/result");
            Response.Redirect(redirect);
}

II. Result page

On the result page we evaluate the authentication request using aducid.getResult

There are two basic results – authentication is OK or an error is thrown:

protected void Page_Load(object sender, EventArgs e)
        {
            var queryString = HttpContext.Current.Request.Url.Query;
            var query = HttpUtility.ParseQueryString(queryString);
 
            var sb = new StringBuilder();
            var aducid = new AducidApiServiceClient();
            try
            {
                var result = aducid.getResult(query.Get("authId"), query.Get("authkey"));
                sb.Append("<table class=\"table table-bordered\">");
                sb.Append("<tr><td>authId:</td><td>" + result.authId + "</td></tr>");
                sb.Append("<tr><td>authKey:</td><td>" + result.authKey + "</td></tr>");
                sb.Append("<tr><td>operationName:</td><td>" + result.operationName + "</td></tr>");
                sb.Append("<tr><td>UDI:</td><td>" + result.userDatabaseIndex + "</td></tr>");
                sb.Append("<tr><td>Status AIM:</td><td>" + result.statusAIM + "</td></tr>");
                sb.Append("<tr><td>Status auth:</td><td>" + result.statusAuth + "</td></tr>");
 
                sb.Append("</table>");
 
            }
            catch (Exception ee)
            {
                sb.Append("Error:" + ee.Message);
            }
            lResponse.Text = sb.ToString();
        }
developers/examples/c-sharp/basic.1477469531.txt.gz · Last modified: 2016/10/26 08:12 by 127.0.0.1