Authentication Class |
public static class Authentication
The Authentication type exposes the following members.
| Name | Description | |
|---|---|---|
| AdministratorExist |
Flag indicating whether atleast one user with Administrator privilege exist in this system.
Return ValueReturns 'true' if atleast one user with Administrator privilege exist in this system, else 'false'. | |
| CurrentPasswordRules | Get the current password requirements of the system. | |
| Enabled | Flag indicating the current state of authentication | |
| InCloudSync | Flag to indicate that the Cloud is in control of user account or group changes to the system. | |
| UserPageAuthEnabled |
Flag indicating the current state of user page authentication.
Return ValueReturns '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. The minimum firmware version required for this method is 1.602.0002 for 3-Series devices and 2.4361.02171 for 4-Series devices. |
| Name | Description | |
|---|---|---|
| ActiveDirectoryLogin |
Active directory login to system.
Requires minimum firmware version 1.601.0017 | |
| ActiveDirectoryLogout | Active directory logout from system | |
| AddGroupToSystem(AuthenticationUserToken, String, AuthenticationUserAuthenticationLevelEnum) | Obsolete. Add group to system | |
| AddGroupToSystem(AuthenticationUserToken, String, AuthenticationUserAuthenticationLevelEnum) | Add group to system | |
| AddUserToGroup(AuthenticationUserToken, String, String) | Add user to group | |
| AddUserToGroup(AuthenticationUserToken, String, String, String) | Obsolete. Add user to group | |
| AddUserToGroup(AuthenticationUserToken, String, String, String) | Add user to group | |
| AddUserToSystem(AuthenticationUserToken, String, String) | Obsolete. add user to system | |
| AddUserToSystem(AuthenticationUserToken, String, String) | add user to system | |
| Disable(AuthenticationUserToken) |
Method to disable authentication on the control system.
SSL state and user information will remain in their current state. | |
| Disable(AuthenticationUserToken, Boolean) | Method to disable authentication on the control system. | |
| Disable(AuthenticationUserToken, Boolean, Boolean) | Method to disable authentication on the control system. | |
| Enable | Method to enable authentication on the control system. | |
| GetAccessLevelForSpecifiedUser | Method to return the access level of the specified user. This returns AuthenticationUserAuthenticationLevelEnum indicating the access level. | |
| GetAuthenticationToken(String, String) | Get authentication token for this user. For use for administering local groups and users or once a domain has been added. | |
| GetAuthenticationToken(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. | |
| GetAuthenticationToken(String, String, String, String) | Get authentication token for the local user and validate the given domain user. | |
| GetGroups |
Method to return the current list of groups and each of its access level in this system.
Requires minimum firmware version 1.601.0017 | |
| GetGroupsForSpecifiedUser | Method to return the groups that the specified user belongs to. This returns AuthenticationUserAuthenticationLevelEnum containing the groups. | |
| GetUsers |
Method to return the current list of users that have access to this system.
Requires minimum firmware version 1.502.0009 | |
| ReleaseAuthenticationToken | This function releases the authentication token, obtained by calling the GetAuthentication method. | |
| RemoveGroupFromSystem(AuthenticationUserToken, String) | Obsolete. Remove an access group from the system | |
| RemoveGroupFromSystem(AuthenticationUserToken, String) | Remove an access group from the system | |
| RemoveUserFromGroup(AuthenticationUserToken, String, String) | Obsolete. Remove a user account from an access group | |
| RemoveUserFromGroup(AuthenticationUserToken, String, String) | Remove a user account from an access group | |
| RemoveUserFromSystem(AuthenticationUserToken, String) | Obsolete. Remove a user account from the control system list of users | |
| RemoveUserFromSystem(AuthenticationUserToken, String) | Remove a user account from the control system list of users | |
| SetUserPageAuthentication | Method to enable or disable user page authentication. | |
| UpdatePassword(AuthenticationUserToken, String, String) | Method to update the password for a specified local user. | |
| UpdatePassword(AuthenticationUserToken, String, String, String) | Method to update the password for a specified local user. | |
| ValidatePassword(String, AuthenticationePasswordRules, String) | Validate a password satisfies all system cuurent password rules | |
| ValidatePassword(String, String, AuthenticationePasswordRules, String) | Validate a password satisfies all system cuurent password rules | |
| ValidateUserInformation | Return information about the specified user information |
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); } } }