Click or drag to resize

Authentication Class

User data class
Inheritance Hierarchy
SystemObject
  Crestron.SimplSharp.CrestronAuthenticationAuthentication

Namespace: Crestron.SimplSharp.CrestronAuthentication
Assembly: SimplSharpHelperInterface (in SimplSharpHelperInterface.dll) Version: 2.21.121
Syntax
C#
public static class Authentication

The Authentication type exposes the following members.

Properties
 NameDescription
Public propertyStatic memberAdministratorExist Flag indicating whether atleast one user with Administrator privilege exist in this system.

Return Value

Returns 'true' if atleast one user with Administrator privilege exist in this system, else 'false'.
Public propertyStatic memberCurrentPasswordRules Get the current password requirements of the system.
Public propertyStatic memberEnabled Flag indicating the current state of authentication
Public propertyStatic memberInCloudSync Flag to indicate that the Cloud is in control of user account or group changes to the system.
Public propertyStatic memberUserPageAuthEnabled Flag indicating the current state of user page authentication.

Return Value

Returns 'false' if user page authentication is disabled, 'true' if user page authentication is enabled.The method is not currently supported.

If minimum firmware version requirement is not satisfied.

Remarks
The minimum firmware version required for this method is 1.602.0002 for 3-Series devices and 2.4361.02171 for 4-Series devices.
Top
Methods
 NameDescription
Public methodStatic memberActiveDirectoryLogin Active directory login to system.

Requires minimum firmware version 1.601.0017

Public methodStatic memberActiveDirectoryLogout Active directory logout from system
Public methodStatic memberAddGroupToSystem(AuthenticationUserToken, String, AuthenticationUserAuthenticationLevelEnum)Obsolete.
Add group to system
Public methodStatic memberAddGroupToSystem(AuthenticationUserToken, String, AuthenticationUserAuthenticationLevelEnum) Add group to system
Public methodStatic memberAddUserToGroup(AuthenticationUserToken, String, String)Add user to group
Public methodStatic memberAddUserToGroup(AuthenticationUserToken, String, String, String)Obsolete.
Add user to group
Public methodStatic memberAddUserToGroup(AuthenticationUserToken, String, String, String)Add user to group
Public methodStatic memberAddUserToSystem(AuthenticationUserToken, String, String)Obsolete.
add user to system
Public methodStatic memberAddUserToSystem(AuthenticationUserToken, String, String) add user to system
Public methodStatic memberDisable(AuthenticationUserToken) Method to disable authentication on the control system.

SSL state and user information will remain in their current state.

Public methodStatic memberDisable(AuthenticationUserToken, Boolean) Method to disable authentication on the control system.
Public methodStatic memberDisable(AuthenticationUserToken, Boolean, Boolean) Method to disable authentication on the control system.
Public methodStatic memberEnable Method to enable authentication on the control system.
Public methodStatic memberGetAccessLevelForSpecifiedUser Method to return the access level of the specified user. This returns AuthenticationUserAuthenticationLevelEnum indicating the access level.
Public methodStatic memberGetAuthenticationToken(String, String) Get authentication token for this user. For use for administering local groups and users or once a domain has been added.
Public methodStatic memberGetAuthenticationToken(String, String, String) Get authentication token for the specified user from the provided IPAddress.

IP address will be blocked if invalid user login attempts exceeds the set value.

Public methodStatic memberGetAuthenticationToken(String, String, String, String) Get authentication token for the local user and validate the given domain user.
Public methodStatic memberGetGroups Method to return the current list of groups and each of its access level in this system.

Requires minimum firmware version 1.601.0017

Public methodStatic memberGetGroupsForSpecifiedUser Method to return the groups that the specified user belongs to. This returns AuthenticationUserAuthenticationLevelEnum containing the groups.
Public methodStatic memberGetUsers Method to return the current list of users that have access to this system.

Requires minimum firmware version 1.502.0009

Public methodStatic memberReleaseAuthenticationToken This function releases the authentication token, obtained by calling the GetAuthentication method.
Public methodStatic memberRemoveGroupFromSystem(AuthenticationUserToken, String)Obsolete.
Remove an access group from the system
Public methodStatic memberRemoveGroupFromSystem(AuthenticationUserToken, String) Remove an access group from the system
Public methodStatic memberRemoveUserFromGroup(AuthenticationUserToken, String, String)Obsolete.
Remove a user account from an access group
Public methodStatic memberRemoveUserFromGroup(AuthenticationUserToken, String, String) Remove a user account from an access group
Public methodStatic memberRemoveUserFromSystem(AuthenticationUserToken, String)Obsolete.
Remove a user account from the control system list of users
Public methodStatic memberRemoveUserFromSystem(AuthenticationUserToken, String) Remove a user account from the control system list of users
Public methodStatic memberSetUserPageAuthentication Method to enable or disable user page authentication.
Public methodStatic memberUpdatePassword(AuthenticationUserToken, String, String) Method to update the password for a specified local user.
Public methodStatic memberUpdatePassword(AuthenticationUserToken, String, String, String) Method to update the password for a specified local user.
Public methodStatic memberValidatePassword(String, AuthenticationePasswordRules, String) Validate a password satisfies all system cuurent password rules
Public methodStatic memberValidatePassword(String, String, AuthenticationePasswordRules, String) Validate a password satisfies all system cuurent password rules
Public methodStatic memberValidateUserInformation Return information about the specified user information
Top
Example
This example program adds a console command to create a token with GetAuthenticationToken(), then adds another command to call GetUsers() with the token
C#
using System;
using System.Collections.Generic;
using Crestron.SimplSharp;                              // For Basic SIMPL# Classes
using Crestron.SimplSharpPro;                           // For Basic SIMPL#Pro classes
using Crestron.SimplSharp.CrestronAuthentication;

public class ControlSystem : CrestronControlSystem
{
    Authentication.UserToken adminToken;
    bool hasToken;

    public ControlSystem()
    {
        try
        {    
            CrestronConsole.AddNewConsoleCommand(CreateToken, "createtoken", "usage: createtoken username password", ConsoleAccessLevelEnum.AccessAdministrator);
        }
        catch (Exception e)
        {
            ErrorLog.Error("Error in the constructor: {0}", e.Message);
        }
    }

    // Create a token for an admin user, or print an error message if the credentials of an existing admin are not provided
    public void CreateToken(string args)
    {
        try
        {
            string userName = args.Split(' ')[0];
            string password = args.Split(' ')[1];
            if (hasToken)
            {
                Authentication.ReleaseAuthenticationToken(adminToken);
                hasToken = false;
            }
            adminToken = Authentication.GetAuthenticationToken(userName, password);
            if (adminToken.Valid)
            {
                if ((adminToken.Access & Authentication.UserAuthenticationLevelEnum.Administrator)
                        == Authentication.UserAuthenticationLevelEnum.Administrator)
                {
                    CrestronConsole.ConsoleCommandResponse("Admin Token created\r\n");
                    CrestronConsole.AddNewConsoleCommand(SeeAllUsers, "SeeAllU", "See all the users on the control system", ConsoleAccessLevelEnum.AccessAdministrator);
                    hasToken = true;
                }
                else
                {
                    CrestronConsole.ConsoleCommandResponse("Inputted credentials are not for an admin account");
                    Authentication.ReleaseAuthenticationToken(adminToken);
                }
            }
            else
            {
                CrestronConsole.ConsoleCommandResponse("The specified username/password pair is incorrect");
            }

        }
        catch (Exception e)
        {
            CrestronConsole.ConsoleCommandResponse("Error in CreateToken: {0}", e);
        }
    }

    public void SeeAllUsers(string args)
    {
        try
        {
            if (adminToken.Valid &&
                (adminToken.Access & Authentication.UserAuthenticationLevelEnum.Administrator)
                        == Authentication.UserAuthenticationLevelEnum.Administrator)
            {
                List<string> users = Authentication.GetUsers(adminToken);
                CrestronConsole.ConsoleCommandResponse("User List:\r\n\r\n");
                if (users == null)
                {
                    CrestronConsole.ConsoleCommandResponse("Error encountered in GetUsers()");
                }
                else if (users.Count == 0)
                {
                    CrestronConsole.PrintLine("No Users");
                }
                else
                {
                    CrestronConsole.ConsoleCommandResponse("User\t\t\t\tAccess Level\r\n");
                    foreach (var user in users)
                    {
                        CrestronConsole.ConsoleCommandResponse("{0}", user);
                        CrestronConsole.ConsoleCommandResponse("\t\t\t{0}\r\n", Authentication.GetAccessLevelForSpecifiedUser(adminToken, user));
                    }
                }
            }
            else
            {
                CrestronConsole.ConsoleCommandResponse("Invalid adminToken provided");
            }
        }
        catch (Exception e)
        {
            CrestronConsole.ConsoleCommandResponse("Error in SeeAllUsers(): {0}", e);
        }
    }
}

Version Information

.NET

Supported in: 6.0

.NET Compact Framework

Supported in: 3.5
See Also