Logon API with Active Directory Explained

  • Updated

This article explains the basic logon APIs in relation to Active Directory.

The snippets are simple examples of the different Ektron APIs. The comments provide additional information on the parameters and any special considerations.

Here are some of the parameters explained:

        // Domain Controller Connection String Format
        string domain = "DC=mysite,DC=com"; // this is an example "mysite.com" 
        // Parameters:
        //   username:    The system username.
        //   Password:    The system password.
        //   ServerName:  The system server name.
        //   Domain:      The user's domain, required only when users login using Active Directory.
        //   Protocol:    Required only when using a secure login or when you are using any valid Active Directory protocols. 
        //   AutoAddType: The desired EkEnumeration.AutoAddUserTypes type

This is the legacy UserAPI, which has an additional method for logging users automatically via SSO (Single Sign On):

        // Pre-8.50 Ektron User API
        Ektron.Cms.UserAPI m_refUserApi = new Ektron.Cms.UserAPI();
        strProtocol = m_refUserApi.AuthProtocol;
        Ektron.Cms.Common.EkEnumeration.AutoAddUserTypes m_eAutoAddType = Ektron.Cms.Common.EkEnumeration.AutoAddUserTypes.Member;

        // This method will log a user with the user provided credentials
        Ektron.Cms.UserData UserInfo = m_refUserApi.logInUser(strUsername, strPassword, Request.ServerVariables["SERVER_NAME"], strDomain, strProtocol, m_eAutoAddType);

        // This method will log the user with information passed through single sign
        Ektron.Cms.UserData UserInfo = m_refUserApi.autologInUser(uxUserName.Text, domain, Request.ServerVariables["SERVER_NAME"], m_eAutoAddType);

        // This needs to be performed for legacy APIs. New framework automatically sets the ecm session cookie.
        if (UserInfo.Id > 0)
        {// On succesful login one must set the authentication cookie for ecm
            Response.Write("Logged In");

This is the newer Ektron Framework UserManager API:

        //Post-8.50  Ektron UserManager Framework API with Active Directory Domain
        Ektron.Cms.Framework.User.UserManager uman = new Ektron.Cms.Framework.User.UserManager(Ektron.Cms.Framework.ApiAccessMode.Admin);
        Ektron.Cms.UserData userdata = uman.Login(uxUserName.Text, uxPassword.Text, domain);

Here is a complete sample on a Clickless Auto Sign In with AD SSO.