UserLock API
Classes | Public Member Functions | Static Public Member Functions | Properties | List of all members
UserLockServer Class Reference

Instance of a local or remote UserLock server. More...

Inherits IDisposable, IDisposable, and IDisposable.

Classes

interface  IOperationNotify
 Interface for callback classes used in ExecuteOperation. More...
 
interface  IOperationParams
 Interface base to operation params in ExecuteOperation method. More...
 
class  SendPopupParams
 Parameters to send popup operation. More...
 
class  ShutdownParams
 Parameters to shutdown operation. More...
 
class  Statistic
 Represents a statistic element. More...
 
class  TaskAsync
 Represents an asynchornous task element. More...
 
class  TaskAsyncResult
 Represents an asynchronous task result.
More...
 

Public Member Functions

 UserLockServer (string serverName)
 Create an instance of UserLockServer by providing the address of the UserLock server.
 
 UserLockServer ()
 Create an instance of UserLockServer connected to the local UserLock service.
 
string GetConnectionString ()
 Gets the connection string to the database used by the UserLock server.
 
int TestUserLockSession (string userName, string computerName, string clientName, string clientIps, SessionType sessionType, DateTime dateTime, out bool isAllowed, out string ulSrvAnswer)
 Tests if a new UserLock session would be allowed or denied.
 
string TestUserLockSession (string userName)
 Tests if a new UserLock session would be allowed or denied.
 
bool CheckAdminCredentials (string account, string domain, string password)
 Check if the credentials for an admin account are valid.
 
void Refresh ()
 Refresh specific UserLock data.
 
void Refresh (ServerDataElement elements)
 Refresh all UserLock data.
 
void Reconnect ()
 Reconnect to the UserLock server.
 
string GetEnforceSync ()
 Enforce synchronization with the primary server. This command can only be sent to a backup server.
 
string GetEnforceSessionSync ()
 Enforce session synchronization with the primary server. This command can only be sent to a backup server.
 
List< ReportedUserGetOrphanedUsers ()
 Get all orphaned users.
 
bool ResetMFAKey (string UserName)
 Resets the MFA key for the provided user account name.
 
void DisableMFA (string accountName, DateTime startDate, DateTime endDate)
 Disable MFA for the provided account name.
 
void DisableMFAAndResetMFAHelpMeStatus (string accountName, DateTime startDate, DateTime endDate)
 Disable MFA and reset the MFA help me status for the provided account name.
 
TaskAsync RestartServiceAsync (string serviceName, string computerName=".")
 Restart service on computer.
 
bool CanTestMfaUrl ()
 Checks if the MFA IIS URL is relative or not.
 
bool TestMfaUrl (out string errorMessage, string publicUrl="", string privateUrl="")
 Tests the MFA URL.
 
IList< EnabledPolicies > GetEnabledPolicies ()
 Retrive a list of all enabled policies on the server.
 

Static Public Member Functions

static void UrlDecode (ref String sToDecode)
 URL decode the parameter string according to the HTML URL Encoding Reference (https://www.w3schools.com/TAGS/ref_urlencode.asp).
 
static void UrlEncode (ref String s, bool bEncodeSlash=true, bool bEncodeComma=false, bool bEncodePr100=true, bool bEncodeColon=true, bool bEncodeBackS=true, bool bEncodeAster=true, bool bEncodeSemiC=true, bool bEncodeParLe=true, bool bEncodeParRi=true, bool bEncodeNewLi=true)
 URL encode the parameter string according to the HTML URL Encoding Reference (https://www.w3schools.com/TAGS/ref_urlencode.asp).
 
static string CombineUrl (string baseUrl, string pathToAdd)
 

Properties

ClientServerCompatibility ServerCompatibility [get]
 Compatibility between the client and the server.
 
Version ClientCommandSetVersion [get]
 The version of the command set of the client.
 
Version ServerCommandSetVersion [get]
 The version of the command set of the server.
 
string UserName [get, set]
 The username.
 
string DomainName [get, set]
 The domain name.
 
string Password [get, set]
 The password.
 
Exception ConnectionException [get]
 Get the last exception generated by the client/server communication. See the example in the constructor of the class UserLockServer.
 
string ConnectionStringWithoutPassword [get]
 Get the connection string to the database used by the UserLock server for the logon history.
 
ServerProperties Properties [get]
 Get the server properties. See the ServerProperties class for more information.
 
MinMaxSessionCounts MinMaxSessionCounts [get]
 The min and max session counts.
 
LicenseStatus LicenseStatus [get]
 Get the license status for the UserLock server. See the enum LicenseStatus for all possible values.
 
LicenseUseStatus LicenseUseStatus [get]
 Use of the license. See the LicenseUseStatus enum for all possible values.
 
bool IsSmtpConfigured [get]
 true if E-mail settings for notifications are configured, false otherwise.
 
bool AdminCredentialsStatus [get]
 true if the credentials of the impersonation account are valid, false otherwise.
 
ProtectedAccounts ProtectedAccounts [get]
 Get the list of all protected accounts configured on the UserLock server.
 
Messages Messages [get]
 Get the list of all customizable message from the UserLock server.
 
ReportedUserSessions UserSessions [get]
 Interactive user sessions.
 
ReportedUserSessions AllUserSessions [get]
 All user sessions.
 
ReportedUserSessions UserSessionsWithSessionOnly [get]
 Users with sessions.
 
ReportedUserSessions UserSessionsActiveSessionsOnly [get]
 Active user sessions (not locked and not disconnected).
 
ReportedUserSessions UserSessionsWithMoreOneSessionOnly [get]
 Users with more than one session.
 
ReportedUserSessions UserSessionsComputerUnavailableOnly [get]
 Users with orphaned sessions (sessions on unreachable computers).
 
ReportedUserSessions UserSessionsLockedSessionsOnly [get]
 Locked user sessions.
 
ReportedUserSessions UserSessionsWorkstationSessionsOnly [get]
 workstation user sessions.
 
ReportedUserSessions UserSessionsTerminalSessionsOnly [get]
 terminal user sessions.
 
ReportedUserSessions UserSessionsIisSessionsOnly [get]
 iis user sessions.
 
ReportedUserSessions UserSessionsVpnSessionsOnly [get]
 vpn user sessions.
 
ReportedUserSessions UserSessionsWifiSessionsOnly [get]
 wifi user sessions.
 
ReportedUserSessions UserSessionsSaasSessionsOnly [get]
 saas user sessions.
 
ReportedUserSessions UserSessionsWithActiveUser [get]
 user sessions with active user.
 
ReportedUserSessions UserSessionsWithProtectedUser [get]
 user sessions with protected user.
 
ReportedUserSessions UserSessionsWithUnprotectedUser [get]
 user sessions with unprotected user.
 
ReportedUserSessions UserSessionsWithHighRiskUser [get]
 user sessions with high risk user.
 
ReportedUserSessions UserSessionsWithRiskUser [get]
 user sessions with risk user.
 
ReportedUserSessions UserSessionsWithNewUser [get]
 user sessions with new user.
 
ReportedUserSessions UserSessionsWithInactiveUser [get]
 user sessions with inactive user.
 
ReportedUserSessions UserSessionsWithOneSessionOnly [get]
 user sessions with inactive user.
 
ReportedMachineSessions MachineSessions [get]
 All machine sessions.
 
ReportedMachineSessions MachineSessionsWithSessionOnly [get]
 Machines with sessions.
 
ReportedMachineSessions MachineSessionsActiveSessionsOnly [get]
 Active machine sessions (not locked and not disconnected).
 
ReportedMachineSessions MachineSessionsComputerUnavailableOnly [get]
 Machines with orphaned sessions (sessions on unreachable computers).
 
ReportedMachineSessions MachineSessionsWithMoreOneSessionOnly [get]
 Machines with more than one session.
 
ReportedMachineSessions MachineSessionsWithOneSessionOnly [get]
 Machines with only one session.
 
ReportedRasSessions RasUserSessions [get]
 Wi-Fi / VPN (RAS) user sessions.
 
List< ReportedMachineReportedMachinesSimpleEx [get]
 List of workstations with the number of sessions on each workstation, and optionally the username. User and session information is optionally provided. This is a public command. Anyone can get this information.
 
MachineStates AgentDistributionDCOnly [get]
 Agent status for all domain controllers in the protected network zone.
 
MachineStates AgentDistributionMacOnly [get]
 Agent status for all macOS computers in the protected network zone.
 
int TotalSessionCount [get]
 The total number of sessions.
 
int TotalUserCount [get]
 The total number of users.
 
int CurrentNumberLicencesConsumed [get]
 The current number of licenses consumed.
 
int NumberLicencesConsumedOneYearMax [get]
 The probable number of licenses that could be consumed after one year of use of the software if you only protect Interactive sessions (twice the number of Desktop UserLock agents installed). This number is not realistic if you are protecting IIS, Wi-Fi, or VPN sessions.
 
int NumberLicencesConsumedOneYearProbablyInteractive [get]
 The probable number of licenses that could be consumed after one year of use of the software if you only protect Interactive sessions (twice the number of Desktop UserLock agents installed). This number is not realistic if you are protecting IIS, Wi-Fi, or VPN sessions.
 
int MaxSessionCount [get]
 This property is obsolete. Use MaxNumberConsumableLicences instead.
 
int MaxNumberConsumableLicences [get]
 The maximum number of consumable licenses.
 
bool IsSubscription [get]
 The licensing mode, true if subscriptive.
 
bool IsByUser [get]
 The licensing mode, true if by users.
 
bool Connected [get]
 True if the instance of UserLockServer is connected to a UserLock server. False otherwise.
 

Asynchronous task management

enum  OperationType
 Operation types for ExecuteOperation method.
 
List< TaskAsyncResultQueryStateAsyncTask (ref TaskAsync taskAsync)
 Queries the state asynchronous task.
 
bool UnsubcribeQueryAsyncTask (TaskAsync taskAsync)
 Unsubcribes the query asynchronous task. After this method, it is not possible to query any more the task state, but the asynchronous task is working on.
 
bool CancelAsyncTask (TaskAsync taskAsync)
 Cancels the asynchronous task.
 
bool ExecuteOperation (OperationType operationType, string[] itemKeys, IOperationParams operationParams, IOperationNotify callBackInstance)
 Executes one operation.
 

General properties

string ServerName [get, set]
 Get or set the address of the UserLock server. Specify a dot (.) for a local server.
 
string ServerAddress [get]
 Get the address of the UserLock server. A null value is returned for a local server.
 
static string LocalMachineName [get]
 Get the name of the local machine the UserLock API is running on.
 
string DisplayName [get]
 Get the display name (NetBIOS name) of the UserLock server.
 
string ServiceVersion [get]
 Get the version of the UserLock service.
 
string UserLockServerDomainName [get]
 Get the domain name (NetBIOS name) of the UserLock server.
 
System.Collections.Specialized.StringDictionary IllegitimateServerNames [get]
 The illegitimate server names.
 
ServerMode ServerType [get]
 Get the server type. See the enum ServerMode for more information.
 
string BackupServer [get]
 The name of the backup server, if any.
 

Session properties and functions

List< ReportedUserReportedUsers [get]
 List of users with the list of interactive sessions for each. See the class ReportedUser.
 
List< ReportedUserAllReportedUsers [get]
 List of users with the list of all kind of sessions for each. See the class ReportedUser.
 
List< ReportedUserReportedUsersWithMoreThanOneSession [get]
 List of users with more than one session.
 
List< ReportedUserActiveReportedUsers [get]
 List of users with an active status (protected + unprotected). See the enum UserStatus.
 
List< ReportedUserProtectedReportedUsers [get]
 List of users with an protected status. See the enum UserStatus.
 
List< ReportedUserUnprotectedReportedUsers [get]
 List of users with an unprotected status. See the enum UserStatus.
 
List< ReportedUserHighRiskReportedUsers [get]
 List of users with an high risk status. See the enum UserStatus.
 
List< ReportedUserRiskReportedUsers [get]
 List of users with a risk status. See the enum UserStatus.
 
List< ReportedUserNewReportedUsers [get]
 List of users with a new status. See the enum UserStatus.
 
List< ReportedUserInactiveReportedUsers [get]
 List of users with an inactive status. See the enum UserStatus.
 
List< ReportedUserReportedUsersWithOneSessionOnly [get]
 List of users with only one session.
 
List< SessionAllSessions [get]
 Get all sessions from any kind.
 
List< InteractiveSessionInteractiveSessions [get]
 Get all interactive sessions.
 
List< RasSessionRasSessions [get]
 Get the list of Wi-Fi / VPN sessions. See the class RasSession.
 
List< IisSessionIisSessions [get]
 Get the list of IIS sessions. See the class IisSession.
 
List< ReportedMachineReportedMachines [get]
 Get the list of computers with the list of interactive sessions on each computer. See the class ReportedMachine.
 
List< ReportedMachineReportedMachinesSimple [get]
 List of workstations with only the number of sessions on each workstation. User and session information is not provided. This is a public command. Anyone can get this information.
 
ReportedUser GetReportedUser (string userName)
 Get interactive sessions for a specific user. See the class ReportedUser.
 
ReportedMachine GetReportedMachine (string machineName)
 Get interactive sessions on a specific computer. See the class ReportedMachine.
 

Agent distribution

Machines MachineDistribution [get]
 Get the all machines with all agent inside of the protected network zone.
 
Machines MachineDistributionAll [get]
 Get all machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionDCOnly [get]
 Get Domain Controller machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionRRASOnly [get]
 Get RRAS machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionNPSOnly [get]
 Get NPS machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionIISOnly [get]
 Get IIS machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionUnavailable [get]
 Get Unavailable machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionWithoutAgent [get]
 Get machines without agent inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionMACOnly [get]
 Get Mac machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionWithAgent [get]
 Get machines with agent inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionWorkstation [get]
 Get Workstation machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionServer [get]
 Get Server machines inside of the protected network zone. See the class Machines.
 
Machines MachineDistributionDesktop [get]
 Get machines, inside of the protected network zone, where agent desktop can be installed. See the class Machines.
 
MachineStates AgentDistribution [get]
 Get the agent status for all machines of the protected network zone.
 
MachineStates AgentDistributionWithoutAgent [get]
 Get the agent status for all machines of the protected network zone without the agent installed.
 
MachineStates AgentDistributionUnavailable [get]
 Get the agent status for all unavailable machines of the protected network zone.
 
AgentDistributionProperties AgentDistributionProperties [get]
 Get the agent distribution properties of the UserLock server. See the class AgentDistributionProperties for more information.
 

Statistics

SessionStatisticMode SessionStatisticMode [get, set]
 Get set the session statistic mode. See the enum SessionStatisticMode.
 
Statistic[] SessionStatistics [get]
 Get session statistics (Session break down Orphaned/Locked Interactive/Active Interactive/RAS/IIS). See also the class Statistic.
 
Statistic[] UserStatistics [get]
 Get user statistics (0 session/1 session/More than 1 session). See also the class Statistic.
 
Statistic[] UserStatusStatistics [get]
 Get user status statistics (high risk/risk/new/inactive/protected/unprotected). See also the class Statistic.
 
Statistic[] MachineStatistics [get]
 Get machine statistics (0 session/1 session/> 1 session). See also the class Statistic.
 
Statistic[] AgentDistributionStatistics [get]
 Get agent statistic (Not Installed/Installed/Unknown/Installing/Uninstalling/Upgrading). See also the class Statistic.
 
Statistic[] AgentTypeStatistics [get]
 Agent type statistics (Desktop, DC, NPS, IIS, RRAS (deprecated)). See also the Statistic class.
 
Statistic[] MachineStateStatistics [get]
 Get ServerLevel statistic (DC/IAS/IIS/RRAS(deprecated)....). See also the class Statistic.
 
Statistic[] ProtectedAccountStatistics [get]
 Get Protected account statistic (OU / Groups / Users). See also the class Statistic.
 
HashSet< String > MfaNeedHelpUserList [get]
 Get the list of users needing help for mfa.
 
Statistic[] MachineEnvironmentStatistics [get]
 Get Machine Environment statistics. See also the class Statistic.
 
Statistic[] UserEnvironmentStatistics [get]
 Get User Environment statistics. See also the class Statistic.
 
Statistic[] MonitoringSessionsStatistics [get]
 Get monitoring sessions statistics. See also the class Statistic.
 
Statistic[] MonitoringUserSessionsStatistics [get]
 Get monitoring user sessions statistics. See also the class Statistic.
 
Statistic[] MonitoringMachineSessionsStatistics [get]
 Get monitoring machine sessions statistics. See also the class Statistic.
 

Quota management functions

TimeQuotaStatus GetUserQuotaStatus (string userAccount)
 Get the quota status for a user. See the documentation of the class TimeQuotaStatus.
 
void DecreaseConsumedTime (string userAccount, SessionType sessionType, TimeQuota.Period period, int minutes)
 Decrease the time consumed by a user for a specific type of session and quota period.
 
void DecreaseConsumedTime (string userAccount, SessionType sessionType, TimeQuota.Period period, TimeSpan timeToDecrease)
 Decrease the time consumed by a user for a specific type of session and quota period.
 
void ResetConsumedTime (string userAccount)
 Reset the time consumed by a user to 0 for all types of session and all quota periods.
 
void ResetConsumedTime (string userAccount, SessionType sessionType, TimeQuota.Period period)
 Reset the time consumed by a user to 0 for a specific type of session and quota period.
 

Protected account management functions

ProtectedAccount GetProtectedAccount (string identifier)
 Get a temporary protected account by its identifier.
 
ProtectedAccount GetProtectedAccount (string identifier, ProtectedAccountBase.AccountPropertyList propertyList)
 Get a protected account.
 
ProtectedAccount GetTemporaryProtectedAccount (string accountName, DateTime startDate, DateTime endDate)
 Gets the temporary protected account from the account name and start and end dates.
 
ProtectedAccountEffective GetProtectedAccountEffective (string accountName, ProtectedAccountBase.AccountPropertyList propertyList, ProtectedAccount.ComplexEffRestsPropertyList cersPropertyList)
 Get effective restrictions of a user (depending on the policy).
 
bool DoesProtectedAccountExist (string accountName)
 Check if a protected account exists.
 
bool AddProtectedGroup (string groupName, out ProtectedAccount paRet)
 Add a new protected group and return it if succeeded.
 
bool AddProtectedGroup (string groupName)
 Add a new protected group.
 
bool AddProtectedUser (string userName, out ProtectedAccount paRet)
 Add a new protected user and return it if succeeded.
 
bool AddProtectedUser (string userName)
 Add a new protected user.
 
bool AddProtectedOu (string ouDistinguishedName, out ProtectedAccount paRet)
 Add a new protected organizational unit and return it if succeeded.
 
bool AddProtectedOu (string ouDistinguishedName)
 Add a new protected organizational unit.
 
bool AddProtectedAccount (string accountName, ProtectedAccountType pat)
 Add a protected account by its name and its type.
 
bool AddProtectedAccount (string accountName, ProtectedAccountType pat, string idPaToCopyCfgFrom)
 Add a protected account by its name, its type and another protected account to copy all configuration from.
 
bool AddTemporaryProtectedUser (string accountName, DateTime startDate, DateTime endDate)
 Add a user temporary protected account by its name.
 
bool AddTemporaryProtectedGroup (string accountName, DateTime startDate, DateTime endDate)
 Add a group temporary protected account by its name.
 
bool AddTemporaryProtectedOu (string accountName, DateTime startDate, DateTime endDate)
 Add a OU temporary protected account by its name.
 
bool AddTemporaryProtectedUser (string accountName, DateTime startDate, DateTime endDate, out ProtectedAccount paRet)
 Add a user temporary protected account by its name and return it if succeeded.
 
bool AddTemporaryProtectedGroup (string accountName, DateTime startDate, DateTime endDate, out ProtectedAccount paRet)
 Add a group temporary protected account by its name and return it if succeeded.
 
bool AddTemporaryProtectedOu (string accountName, DateTime startDate, DateTime endDate, out ProtectedAccount paRet)
 Add a OU temporary protected account by its name and return it if succeeded.
 
bool AddTemporaryProtectedAccount (string accountName, DateTime startDate, DateTime endDate, ProtectedAccountType pat, out ProtectedAccount paRet)
 Add a temporary protected account by its name, its start and end dates and its type and return it if succeeded.
 
bool AddTemporaryProtectedAccount (string accountName, DateTime startDate, DateTime endDate, ProtectedAccountType pat)
 Add a temporary protected account by its name, its start and end dates and its type.
 
bool AddTemporaryProtectedAccount (string accountName, DateTime startDate, DateTime endDate, ProtectedAccountType pat, bool bCopyCfgFromPrmPa)
 Add a temporary protected account by its name, its start and end dates, its type and a bool to copy the configuration of the corresponding permanent protected account if any.
 
bool AddTemporaryProtectedAccount (string accountName, DateTime startDate, DateTime endDate, ProtectedAccountType pat, string idPaToCopyCfgFrom)
 Add a temporary protected account by its name, its start and end dates, its type and another protected account to copy all configuration from.
 
bool AddProtectedAccount (string accountName, ProtectedAccountType pat, string idPaToCopyCfgFrom, out ProtectedAccount paRet)
 Adds a permanent protected account with its name, the type of account, the ID of another protected account from which the entire configuration is copied, returns if it was successful, and if so returns created object.
 
bool AddTemporaryProtectedAccount (string accountName, DateTime startDate, DateTime endDate, ProtectedAccountType pat, string idPaToCopyCfgFrom, out ProtectedAccount paRet)
 Adds a temporary protected account with its name, the start and end dates, the type of account, the ID of another protected account from which the entire configuration is copied, returns if it was successful, and if so returns created object.
 
bool DeleteProtectedAccount (ProtectedAccount protectedAccount)
 Delete a protected account.
 
bool DeleteProtectedAccount (string accountName)
 Delete a protected account by name.
 
bool DeleteTemporaryProtectedAccount (string accountName, DateTime startDate, DateTime endDate)
 Delete a temporary protected account by its name and start and end dates.
 

Session management

bool Logoff (string session)
 Logoff an interactive session.
 
TaskAsync LogoffAsync (string[] sessions)
 Logoffs interactive and IIS sessions in asynchronous way.
 
bool Logoff (Session session)
 Logoff an interactive session.
 
TaskAsync LogoffAsync (List< Session > sessions)
 Logoffs interactive and IIS sessions in asynchronous way.
 
bool LogoffIis (string session)
 Logoff a IIS session.
 
bool LogoffIis (IisSession session)
 Logoff a IIS session.
 
bool Lock (string session)
 Lock an interactive session by specifying the session name.
 
TaskAsync LockAsync (string[] sessions)
 Locks interactive sessions in asynchronous way.
 
bool Lock (Session session)
 Lock an interactive session.
 
TaskAsync LockAsync (List< Session > sessions)
 Locks interactive sessions in asynchronous way.
 
bool Reset (string session)
 Reset an interactive session.
 
bool ResetRas (string session)
 Reset a RAS session.
 
bool ResetIis (string session)
 Reset a IIS session.
 
bool Reset (Session session)
 Reset a session with a Session instance retrieved from the server.
 
TaskAsync ResetAsync (List< Session > sessions)
 Reset sessions with several Session instances retrieved from the server, in asynchronous way.
 
bool SendPopup (string session, string message)
 Overloaded function to send a popup to an interactive session. See the full version SendPopup(string, string, string) method.
 
TaskAsync SendPopupAsync (string[] sessions, string message)
 Overloaded function to send a popup to several interactive sessions in asynchronous way. See the full version SendPopupAsync(string[], string, string) method.
 
bool SendPopup (string session, string message, string title)
 Send a popup to an interactive session.
 
TaskAsync SendPopupAsync (string[] sessions, string message, string title)
 Sends a popup to several interactive sessions in asynchronous way.
 
bool SendPopup (Session session, string message)
 Overloaded function to shutdown a computer by specifying a Session instance retrieved from the UserLock server. See the full version SendPopup(Session, string, string) method.
 
TaskAsync SendPopupAsync (List< Session > sessions, string message)
 Overloaded function to send a popup to several interactive sessions retrieved from the UserLock server, in asynchronous way. See the full version SendPopupAsync(List<Session>, string, string) method.
 
bool SendPopup (Session session, string message, string title)
 Send a popup to an interactive session with a Session instance retrieved from the server.
 
TaskAsync SendPopupAsync (List< Session > sessions, string message, string title)
 Sends a popup to several interactive sessions in asynchronous way.
 
void SendPopupToUser (string userName, string message)
 Overloaded function to send a popup in all sessions of a specific user. See the full version SendPopupToUser(string, string, string) method.
 
TaskAsync SendPopupAsyncToUsers (string[] userNames, string message)
 Overloaded function to send a popup in all sessions of several specific users in asynchronous way. See the full version SendPopupAsyncToUsers(string[], string, string) method.
 
void SendPopupToUser (string userName, string message, string title)
 Send a popup in all sessions of a specific user.
 
TaskAsync SendPopupAsyncToUsers (string[] userNames, string message, string title)
 Send a popup in all sessions of several specific users in asynchronous way.
 
void SendPopupToMachine (string machineName, string message)
 Overloaded function to send a popup to all sessions on a specific machine. See the full version SendPopupToMachine(string, string, string) method.
 
TaskAsync SendPopupAsyncToMachines (string[] machineNames, string message)
 Overloaded function to send a popup to all sessions on several specific machines in asynchronous way. See the full version SendPopupAsyncToMachines(string[], string, string) method.
 
void SendPopupToMachine (string machineName, string message, string title)
 Send a popup to all sessions on a specific machine.
 
TaskAsync SendPopupAsyncToMachines (string[] machineNames, string message, string title)
 Send a popup to all sessions on several specific machines in asynchronous way.
 
void SendPopupToGroup (string protectedGroupName, string message)
 Overloaded function to send a popup to all members of a protected group or OU. See the full version SendPopupToGroup(string, string, string) method.
 
TaskAsync SendPopupAsyncToGroups (string[] protectedGroupNames, string message)
 Overloaded function to send a popup to all members of several protected groups or OUs in asynchronous way. See the full version SendPopupAsyncToGroups(string[], string, string) method.
 
void SendPopupToGroup (string protectedGroupName, string message, string title)
 Send a popup to all members of a protected group or OU.
 
TaskAsync SendPopupAsyncToGroups (string[] protectedGroupNames, string message, string title)
 Send a popup to all members of several protected groups or OUs in asynchronous way.
 

Agent management

bool InstallAgent (string computer)
 Install the agent for interactive sessions on a workstation or a terminal server.
 
bool InstallRrasAgent (string computer)
 Install the agent for RRAS sessions on a Microsoft RRAS server (deprecated).
 
bool InstallIasAgent (string computer)
 Install the agent for RADIUS sessions on a Microsoft NPS (IAS) server.
 
bool InstallIisAgent (string computer)
 Install the agent for IIS sessions on a Microsoft IIS server.
 
bool InstallAgent (MachineState machineState)
 Install an agent with a MachineState instance retrieved from the server.
 
TaskAsync InstallAgentAsync (List< MachineState > machineStates)
 Install multiple agents asynchronously, specifying MachineState instances retrieved from the UserLock server.
 
bool UninstallAgent (string computer)
 Uninstall the agent for interactive sessions from a workstation or a terminal server.
 
bool UninstallRrasAgent (string computer)
 Uninstall the agent for RRAS sessions from a Microsoft RRAS server (deprecated).
 
bool UninstallIasAgent (string computer)
 Uninstall the agent for RADIUS sessions from a Microsoft IAS/NPS server.
 
bool UninstallIisAgent (string computer)
 Uninstall the agent for IIS sessions from a Microsoft IIS server.
 
bool UninstallAgent (MachineState machineState)
 Uninstall the agent by using a MachineState instance retrieved from the server.
 
TaskAsync UninstallAgentAsync (List< MachineState > machineStates)
 Uninstall agents with several MachineState instances retrieved from the server, in asynchronous way.
 

Computer management

bool Reboot (string computer)
 Reboot a computer.
 
TaskAsync RebootAsync (string[] computers)
 Reboots several computers in asynchronous way.
 
bool Reboot (MachineState machineState)
 Reboot a computer by specifying a MachineState instance retrieved from the UserLock server.
 
TaskAsync RebootAsync (List< MachineState > machineStates)
 Reboot multiple computers asynchronously, specifying MachineState instances retrieved from the UserLock server.
 
bool WakeUp (string computer)
 Wakes up a computer.
 
TaskAsync WakeUpAsync (string[] computers)
 Wakes up several computers in asynchronous way.
 
bool WakeUp (MachineState machineState)
 Wakes up a computer by specifying a MachineState instance retrieved from the UserLock server.
 
TaskAsync WakeUpAsync (List< MachineState > machineStates)
 Wake up multiple computers asynchronously, specifying MachineState instances retrieved from the UserLock server.
 
bool Shutdown (string computer)
 Overloaded function to shutdown a computer. See the full version Shutdown(string, ExecutionMode, NotifyMode, double, ForceMode, string) method.
 
TaskAsync ShutdownAsync (string[] computers)
 Overloaded function to shutdown several computers in asynchronous way. See the full version ShutdownAsync(string[], ExecutionMode, NotifyMode, double, ForceMode, string) method.
 
bool Shutdown (string computer, ExecutionMode executionMode, ForceMode forceMode, string message)
 Overloaded function to shutdown a computer. See the full version Shutdown(string, ExecutionMode, NotifyMode, double, ForceMode, string) method.
 
TaskAsync ShutdownAsync (string[] computers, ExecutionMode executionMode, ForceMode forceMode, string message)
 Overloaded function to shutdown several computers in asynchronous way. See the full version ShutdownAsync(string[], ExecutionMode, NotifyMode, double, ForceMode, string) method.
 
bool Shutdown (string computer, double timeOut, string message)
 Overloaded function to shutdown a computer. See the full version Shutdown(string, ExecutionMode, NotifyMode, double, ForceMode, string) method.
 
TaskAsync ShutdownAsync (string[] computers, double timeOut, string message)
 Overloaded function to shutdown several computers in asynchronous way. See the full version ShutdownAsync(string[], ExecutionMode, NotifyMode, double, ForceMode, string) method.
 
bool Shutdown (string computer, ExecutionMode executionMode, NotifyMode notifyMode, double timeOut, ForceMode forceMode, string message)
 Shutdown a computer.
 
TaskAsync ShutdownAsync (string[] computers, ExecutionMode executionMode, NotifyMode notifyMode, double timeOut, ForceMode forceMode, string message)
 Shutdowns several computers in asynchronous way.
 
bool Shutdown (MachineState machineState)
 Shutdown a computer by specifying a MachineState instance retrieved from the UserLock server.
 
TaskAsync ShutdownAsync (List< MachineState > machineStates)
 Overloaded function to shutdown several computers in asynchronous way, by specifying MachineState instances retrieved from the UserLock server. See the full version ShutdownAsync(List<MachineState>, ExecutionMode, NotifyMode, double, ForceMode, string) method.
 
TaskAsync ShutdownAsync (List< MachineState > machineStates, ExecutionMode executionMode, NotifyMode notifyMode, double timeOut, ForceMode forceMode, string message)
 Shut down multiple computers asynchronously, specifying MachineState instances retrieved from the UserLock server.
 

Database management

bool CreateTable ()
 Create or recreate the UserLogonEvents table where is stored the logon history in the UserLock database.
 
bool CreateTimeIndex ()
 Creates an index on the EventTime field of the UserLogonEvents table to speed up queries on time frames.
 
bool DeleteTimeIndex ()
 Deletes the index on the EventTime field of the UserLogonEvents table.
 
bool ExecuteSqlCommand (string command)
 Executes an SQL command on the UserLock database.
 
bool CompactDatabase ()
 Compacts the default UserLock database.
 
bool CleanOldLogons (int days)
 Removes logon events older than a specific number of days from the logon history database.
 
bool CleanOldLogons (DateTime limitDate)
 Removes logon events older than a specific date from the logon history database.
 
bool CleanAllLogons ()
 Clear all logon events the logon history database.
 
void UnblockAUser (string accountName)
 Unblock a specific account with the provided user name.
 
void BlockAUser (string accountName, bool createPermanentPA, string message, bool closeAllSessions)
 Blocks a specific account with the provided user name (create the related protected account if it doesn't exist).
 
bool ExistingActiveTemporaryProtectedAccount (string protectedAccountName)
 Return True if the provided account name has already an active temporary protected account.
 
void CloseAllSessionAfterBlocking (string protectedAccountName)
 Close all the opened sessions of a protected account after this user has been blocked.
 

Initial Access Point Policy

InitialAccessPointPolicy GetInitialAccessPointPolicy (string paIdentifier)
 Get the InitialAccessPointPolicy for paIdentifier
 
InitialAccessPointPolicy GetTemporaryInitialAccessPointPolicy (string accountName, DateTime startDate, DateTime endDate)
 Get a temporary InitialAccessPointPolicy for accountName.
 
bool AddInitialAccessPointPolicyToGroup (string groupName, out InitialAccessPointPolicy policyRet)
 Add a initial access point policy to a group.
 
bool AddInitialAccessPointPolicyToGroup (string groupName)
 Add a initial access point policy to a group.
 
bool AddInitialAccessPointPolicyToUser (string userName, out InitialAccessPointPolicy policyRet)
 Add a initial access point policy to a User.
 
bool AddInitialAccessPointPolicyToUser (string userName)
 Add a initial access point policy to a User.
 
bool AddInitialAccessPointPolicyToOu (string ouName, out InitialAccessPointPolicy policyRet)
 Add a initial access point policy to a OU.
 
bool AddInitialAccessPointPolicyToOu (string ouName)
 Add a initial access point policy to a OU.
 
bool AddTemporaryInitialAccessPointPolicyToOu (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary initial access point policy to a OU.
 
bool AddTemporaryInitialAccessPointPolicyToOu (string accountName, DateTime startDate, DateTime endDate, out InitialAccessPointPolicy policyRet)
 Add a temporary initial access point policy to a OU.
 
bool AddTemporaryInitialAccessPointPolicyToGroup (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary initial access point policy to a Group.
 
bool AddTemporaryInitialAccessPointPolicyToGroup (string accountName, DateTime startDate, DateTime endDate, out InitialAccessPointPolicy policyRet)
 Add a temporary initial access point policy to a Group.
 
bool AddTemporaryInitialAccessPointPolicyToUser (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary initial access point policy to a User.
 
bool AddTemporaryInitialAccessPointPolicyToUser (string accountName, DateTime startDate, DateTime endDate, out InitialAccessPointPolicy policyRet)
 Add a temporary initial access point policy to a User.
 

Session Limit Policy

SessionLimitPolicy GetSessionLimitPolicy (string paIdentifier)
 Get the SessionLimitPolicy for paIdentifier
 
SessionLimitPolicy GetTemporarySessionLimitPolicy (string accountName, DateTime startDate, DateTime endDate)
 Get a temporary SessionLimitPolicy for accountName.
 
bool AddSessionLimitPolicyToGroup (string groupName, out SessionLimitPolicy policyRet)
 Add a Session Limit policy to a group.
 
bool AddSessionLimitPolicyToGroup (string groupName)
 Add a Session Limit policy to a group.
 
bool AddSessionLimitPolicyToUser (string userName, out SessionLimitPolicy policyRet)
 Add a Session Limit policy to a User.
 
bool AddSessionLimitPolicyToUser (string userName)
 Add a Session Limit policy to a User.
 
bool AddSessionLimitPolicyToOu (string ouName, out SessionLimitPolicy policyRet)
 Add a Session Limit policy to a OU.
 
bool AddSessionLimitPolicyToOu (string ouName)
 Add a Session Limit policy to a OU.
 
bool AddTemporarySessionLimitPolicyToOu (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary Session Limit policy to a OU.
 
bool AddTemporarySessionLimitPolicyToOu (string accountName, DateTime startDate, DateTime endDate, out SessionLimitPolicy policyRet)
 Add a temporary Session Limit policy to a OU.
 
bool AddTemporarySessionLimitPolicyToGroup (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary Session Limit policy to a Group.
 
bool AddTemporarySessionLimitPolicyToGroup (string accountName, DateTime startDate, DateTime endDate, out SessionLimitPolicy policyRet)
 Add a temporary Session Limit policy to a Group.
 
bool AddTemporarySessionLimitPolicyToUser (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary Session Limit policy to a User.
 
bool AddTemporarySessionLimitPolicyToUser (string accountName, DateTime startDate, DateTime endDate, out SessionLimitPolicy policyRet)
 Add a temporary Session Limit policy to a User.
 

Workstation restrictions Policy

WorkstationPolicy GetWorkstationPolicy (string paIdentifier)
 Get the WorkstationPolicy for paIdentifier
 
WorkstationPolicy GetTemporaryWorkstationPolicy (string accountName, DateTime startDate, DateTime endDate)
 Get a temporary WorkstationPolicy for accountName.
 
bool AddWorkstationPolicyToGroup (string groupName, out WorkstationPolicy policyRet)
 Add a Workstation restrictions policy to a group.
 
bool AddWorkstationPolicyToGroup (string groupName)
 Add a Workstation restrictions policy to a group.
 
bool AddWorkstationPolicyToUser (string userName, out WorkstationPolicy policyRet)
 Add a Workstation restrictions policy to a User.
 
bool AddWorkstationPolicyToUser (string userName)
 Add a Workstation restrictions policy to a User.
 
bool AddWorkstationPolicyToOu (string ouName, out WorkstationPolicy policyRet)
 Add a Workstation restrictions policy to a OU.
 
bool AddWorkstationPolicyToOu (string ouName)
 Add a Workstation restrictions policy to a OU.
 
bool AddTemporaryWorkstationPolicyToOu (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary Workstation restrictions policy to a OU.
 
bool AddTemporaryWorkstationPolicyToOu (string accountName, DateTime startDate, DateTime endDate, out WorkstationPolicy policyRet)
 Add a temporary Workstation restrictions policy to a OU.
 
bool AddTemporaryWorkstationPolicyToGroup (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary Workstation restrictions policy to a Group.
 
bool AddTemporaryWorkstationPolicyToGroup (string accountName, DateTime startDate, DateTime endDate, out WorkstationPolicy policyRet)
 Add a temporary Workstation restrictions policy to a Group.
 
bool AddTemporaryWorkstationPolicyToUser (string accountName, DateTime startDate, DateTime endDate)
 Add a temporary Workstation restrictions policy to a User.
 
bool AddTemporaryWorkstationPolicyToUser (string accountName, DateTime startDate, DateTime endDate, out WorkstationPolicy policyRet)
 Add a temporary Workstation restrictions policy to a User.
 

Detailed Description

Instance of a local or remote UserLock server.

Constructor & Destructor Documentation

◆ UserLockServer()

UserLockServer ( string serverName)

Create an instance of UserLockServer by providing the address of the UserLock server.

Parameters
serverNameAddress of the UserLock server (name/FQDN/IP address). Specify a dot (.) if the server is local.

Connect to a local server and check that the connection was successful

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.Connected)
Console.WriteLine(userLockServer.ConnectionException.Message);
Instance of a local or remote UserLock server.
Definition UserLockServer.cs:24
bool Connected
True if the instance of UserLockServer is connected to a UserLock server. False otherwise.
Definition UserLockServerCommon.cs:4669
Exception ConnectionException
Get the last exception generated by the client/server communication. See the example in the construct...
Definition UserLockServerCommon.cs:118

Connect to a remote server and check that the connection was successful

UserLockServer userLockServer = new UserLockServer("SERVERNAME");
if (!userLockServer.Connected)
Console.WriteLine(userLockServer.ConnectionException.Message);

Optimized server disconnection with the using statement. At the end of the scope the API is automatically disconnected from the UserLock server. Do so if you create many instances of the UserLockServer class for short periods.

using (UserLockServer userLockServer = new UserLockServer("tafserver1"))
{
// Do what you have to do
}


Member Function Documentation

◆ TestUserLockSession() [1/2]

int TestUserLockSession ( string userName,
string computerName,
string clientName,
string clientIps,
SessionType sessionType,
DateTime dateTime,
out bool isAllowed,
out string ulSrvAnswer )

Tests if a new UserLock session would be allowed or denied.

Parameters
userNameThe user name.
computerNameThe computer name.
clientNameThe client name.
clientIpsThe client IP(s).
sessionTypeThe session type.
dateTimeThe date time at which to test the logon.
isAllowedIf set to true, a new UserLock session would be allowed.
ulSrvAnswerThe answer of the UserLock server.
Returns
The error code, 0 if no error.
Exceptions
UserExceptionThis method is not supported in UserLock services older than 9 version.

◆ TestUserLockSession() [2/2]

string TestUserLockSession ( string userName)

Tests if a new UserLock session would be allowed or denied.

Parameters
userNameThe user name.
Returns
The answer of the UserLock server.
Exceptions
UserExceptionThis method is not supported in UserLock services older than 9 version.

◆ CheckAdminCredentials()

bool CheckAdminCredentials ( string account,
string domain,
string password )

Check if the credentials for an admin account are valid.

Parameters
accountAccount name
domainDomain of the account
passwordPassword for this account
Returns

◆ GetReportedUser()

ReportedUser GetReportedUser ( string userName)

Get interactive sessions for a specific user. See the class ReportedUser.

Parameters
userNameUser account name
Returns
An instance of the ReportedUser class

Example: Logoff all sessions of the user myuser

UserLockServer userLockServer = new UserLockServer(".")
ReportedUser reportedUser = userLockServer.GetReportedUser("myuser");
foreach (Session userSession in reportedUser.UserSessions)
if (!userLockServer.Logoff(userSession))
Console.WriteLine("Failed to logoff the session {0}. Error: {1}", userSession.DisplayName, userLockServer.Connection.LastMessage);
Represent a user with all his sessions. An element of the property ReportedUsers of the class UserLoc...
Definition ReportedUser.cs:375
Base class for all kind of sessions.
Definition Session.cs:69

◆ GetReportedMachine()

ReportedMachine GetReportedMachine ( string machineName)

Get interactive sessions on a specific computer. See the class ReportedMachine.

Parameters
machineNameName of the computer
Returns
An instance of the ReportedMachine class

Example: Logoff all sessions on the computer MYCOMPUTER.

UserLockServer userLockServer = new UserLockServer(".")
ReportedMachine reportedMachine = userLockServer.GetReportedMachine("MYCOMPUTER");
foreach (Session machineSession in reportedMachine.MachineSessions)
if (!userLockServer.Logoff(machineSession))
Console.WriteLine("Failed to logoff the session {0}. Error: {1}", machineSession.DisplayName, userLockServer.Connection.LastMessage);
Represent a computer with all the sessions on it. This is an element of the property ReportedMachines...
Definition ReportedMachine.cs:139

◆ GetUserQuotaStatus()

TimeQuotaStatus GetUserQuotaStatus ( string userAccount)

Get the quota status for a user. See the documentation of the class TimeQuotaStatus.

Parameters
userAccountUser account name. The domain is needed if the account is from another domain (DOMAIN\account).

Example: Get the quota status for a specific user.

UserLockServer userLockServer = new UserLockServer(".");
TimeQuotaStatus timeQuotaStatus = userLockServer.GetUserQuotaStatus("DOMAIN\user");
Time quota status for a specific user. List consumed time for the user and for all kind of sessions....
Definition TimeQuotaStatus.cs:15
TimeQuotaStatus GetUserQuotaStatus(string userAccount)
Get the quota status for a user. See the documentation of the class TimeQuotaStatus.
Definition UserLockServerCommon.cs:2533

◆ DecreaseConsumedTime() [1/2]

void DecreaseConsumedTime ( string userAccount,
SessionType sessionType,
TimeQuota::Period period,
int minutes )

Decrease the time consumed by a user for a specific type of session and quota period.

Parameters
userAccountUser account name. The domain is needed if the account is from another domain (DOMAIN\account).
sessionTypeType of the session. See SessionType enum.
periodTime quota period. See the enum TimeQuota.Period.
minutesTime length to decrease in minutes.

Example: Decrease the daily consumed time on workstations for a specific user by 1 hour.

UserLockServer userLockServer = new UserLockServer(".");
userLockServer.DecreaseConsumedTime("DOMAIN\user", SessionType.Workstation, TimeQuota.Period.Day, 60);
Time quota for a specific period of time and for specific types of session.
Definition TimeQuota.cs:14
Period
Enum that allows to specify a period of time for time quota. See the Property Periodicity of the clas...
Definition TimeQuota.cs:71
void DecreaseConsumedTime(string userAccount, SessionType sessionType, TimeQuota.Period period, int minutes)
Decrease the time consumed by a user for a specific type of session and quota period.
Definition UserLockServerCommon.cs:2553
SessionType
Different types of sessions. A session has only one type but several types can be specified in severa...
Definition Session.cs:11

◆ DecreaseConsumedTime() [2/2]

void DecreaseConsumedTime ( string userAccount,
SessionType sessionType,
TimeQuota::Period period,
TimeSpan timeToDecrease )

Decrease the time consumed by a user for a specific type of session and quota period.

Parameters
userAccountUser account name. The domain is needed if the account is from another domain (DOMAIN\account).
sessionTypeType of the session. See SessionType enum.
periodTime quota period. See the enum TimeQuota.Period.
timeToDecreaseTime length to decrease.

Example: Decrease the daily consumed time on workstations for a specific user by 1 hour.

UserLockServer userLockServer = new UserLockServer(".");
userLockServer.DecreaseConsumedTime("DOMAIN\user", SessionType.Workstation, TimeQuota.Period.Day, new TimeSpan(1, 0, 0));

◆ ResetConsumedTime() [1/2]

void ResetConsumedTime ( string userAccount)

Reset the time consumed by a user to 0 for all types of session and all quota periods.

Parameters
userAccountUser account name. The domain is needed if the account is from another domain (DOMAIN\account).

Example: Reset the consumed time for a specific user.

UserLockServer userLockServer = new UserLockServer(".");
userLockServer.ResetConsumedTime("DOMAIN\user");
void ResetConsumedTime(string userAccount)
Reset the time consumed by a user to 0 for all types of session and all quota periods.
Definition UserLockServerCommon.cs:2588

◆ ResetConsumedTime() [2/2]

void ResetConsumedTime ( string userAccount,
SessionType sessionType,
TimeQuota::Period period )

Reset the time consumed by a user to 0 for a specific type of session and quota period.

Parameters
userAccountUser account name. The domain is needed if the account is from another domain (DOMAIN\account).
sessionTypeType of the session. See SessionType enum.
periodTime quota period. See the enum TimeQuota.Period.

Example: Reset the daily consumed time on workstations for a specific user.

UserLockServer userLockServer = new UserLockServer(".");
userLockServer.ResetConsumedTime("DOMAIN\user", SessionType.Workstation, TimeQuota.Period.Day);

◆ Refresh()

void Refresh ( )

Refresh specific UserLock data.

Example: Refresh user sessions after reseting a session. The new list of interactive sessions should reflect that the reseted session no longer exists.

UserLockServer userLockServer = new UserLockServer(".");
userLockServer.Reset('COMPUTERNAME/1');
userLockServer.Refresh(ServerDataElement.UserSessions);
foreach (InteractiveSession session in userLockServer.InteractiveSessions)
Console.WriteLine("{0}\n", session.Name);
Class for interactive sessions: workstation sessions and terminal sessions.
Definition Session.cs:340
string Name
Universal key name of the session in order to identify it uniquely over all kind of session (KeyName,...
Definition Session.cs:141
List< InteractiveSession > InteractiveSessions
Get all interactive sessions.
Definition UserLockServerCommon.cs:2354
void Refresh()
Refresh specific UserLock data.
Definition UserLockServerCommon.cs:4588
bool Reset(string session)
Reset an interactive session.
Definition UserLockServerCommon.cs:6658
ServerDataElement
Allows to specify what for information needs to be refreshed from the server. See the Refresh method ...
Definition UserLockServerCommon.cs:8533

◆ GetProtectedAccount() [1/2]

ProtectedAccount GetProtectedAccount ( string identifier)

Get a temporary protected account by its identifier.

OUT: The concerned protected account object, null if no such protected account.

Parameters
identifierIN : The identifier of the protected account.

◆ GetProtectedAccount() [2/2]

ProtectedAccount GetProtectedAccount ( string identifier,
ProtectedAccountBase::AccountPropertyList propertyList )

Get a protected account.

Parameters
identifierThe identifier of the protected account.
propertyListProperties to load from the server. See the enum AccountPropertyList. Optional parameter. By default all properties are loaded.

Example: Get a protected account and display the maximum number of allowed concurrent interactive sessions.

UserLockServer userLockServer = new UserLockServer(".");
ProtectedAccount protectedAccount = userLockServer.GetProtectedAccount("ProtectedAccountName", ProtectedAccountBase.AccountPropertyList.UserLock);
Console.WriteLine("Maximum number of simultaneous interactive sessions for {0}: {1}\n", protectedAccount.Name, protectedAccount.NbConcurrentLogins);
Base class for ProtectedAccount and ProtectedAccountEffective.
Definition ProtectedAccount.cs:57
int NbConcurrentLogins
Maximum number of concurrent interactive sessions (workstation sessions and terminal sessions)....
Definition ProtectedAccount.cs:641
Protected account allowing to define logon rules for a user or a group/organizational unit of users....
Definition ProtectedAccount.cs:1818
ProtectedAccount GetProtectedAccount(string identifier)
Get a temporary protected account by its identifier.
Definition UserLockServerCommon.cs:4681
AccountPropertyList
Enumeration of all groups of properties in the ProtectedAccount class allowing to get or set only sel...
Definition ProtectedAccount.cs:428

◆ GetTemporaryProtectedAccount()

ProtectedAccount GetTemporaryProtectedAccount ( string accountName,
DateTime startDate,
DateTime endDate )

Gets the temporary protected account from the account name and start and end dates.

Parameters
accountNameName of the account.
startDateThe start date.
endDateThe end date.
Returns
The concerned protected account object, null if no such protected account.
Exceptions
UserExceptionThis method is not supported in UserLock services older than 8 version.

◆ GetProtectedAccountEffective()

ProtectedAccountEffective GetProtectedAccountEffective ( string accountName,
ProtectedAccountBase::AccountPropertyList propertyList,
ProtectedAccount::ComplexEffRestsPropertyList cersPropertyList )

Get effective restrictions of a user (depending on the policy).

Parameters
accountNameName of the user account.
propertyListList of properties to calculate. See the enum AccountPropertyList. Optional parameter. By default all properties are loaded.
cersPropertyListList of complex properties to calculate. See the enum ComplexEffRestsPropertyList. Optional parameter. By default all complex properties are loaded.
Returns
Effective restrictions of the user (depending on the policy).

Example: Get effective restrictions of a user and display the maximum number of allowed concurrent interactive sessions.

UserLockServer userLockServer = new UserLockServer(".");
ProtectedAccountEffective protectedAccountEffective = userLockServer.GetProtectedAccountEffective("ProtectedAccountName", ProtectedAccountBase.AccountPropertyList.UserLock);
Console.WriteLine("Maximum number of simultaneous interactive sessions effectives for {0}: {1}\n", protectedAccountEffective.Name, protectedAccountEffective.NbConcurrentLogins);
Effective Protected Account is a virtual protected account (it doesn't exist in the protected account...
Definition ProtectedAccount.cs:3683
ProtectedAccountEffective GetProtectedAccountEffective(string accountName, ProtectedAccountBase.AccountPropertyList propertyList, ProtectedAccount.ComplexEffRestsPropertyList cersPropertyList)
Get effective restrictions of a user (depending on the policy).
Definition UserLockServerCommon.cs:4748

◆ DoesProtectedAccountExist()

bool DoesProtectedAccountExist ( string accountName)

Check if a protected account exists.

Parameters
accountNameName of the protected account.
Returns
Returns true if the protected account exists, false otherwise.

◆ AddProtectedGroup() [1/2]

bool AddProtectedGroup ( string groupName,
out ProtectedAccount paRet )

Add a new protected group and return it if succeeded.

Parameters
groupNameName of the Windows/AD group. Specify the domain name if the group is from another domain (e.g. DOMAINNAME\GroupName).
paRetnull if failed, the created instance if succeeded.
Returns
True if succeeded, False otherwise.

Example: Create a new protected group for everyone

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.AddProtectedGroup("Everyone"))\n
Console.WriteLine("Failed to create the group. Error: {0}\n", userLockServer.Connection.LastMessage);
bool AddProtectedGroup(string groupName, out ProtectedAccount paRet)
Add a new protected group and return it if succeeded.
Definition UserLockServerCommon.cs:4779

◆ AddProtectedGroup() [2/2]

bool AddProtectedGroup ( string groupName)

Add a new protected group.

Parameters
groupNameName of the Windows/AD group. Specify the domain name if the group is from another domain (e.g. DOMAINNAME\GroupName).
Returns
True if succeeded, False otherwise.

Example: Create a new protected group for everyone

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.AddProtectedGroup("Everyone"))\n
Console.WriteLine("Failed to create the group. Error: {0}\n", userLockServer.Connection.LastMessage);

◆ AddProtectedUser() [1/2]

bool AddProtectedUser ( string userName,
out ProtectedAccount paRet )

Add a new protected user and return it if succeeded.

Parameters
userNameName of the Windows/AD user account. Specify the domain name if the account is from another domain (e.g. DOMAINNAME\UserName).
paRetnull if failed, the created instance if succeeded.
Returns
True if succeeded, False otherwise.

Example: Create a new protected account for the user Bob

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.AddProtectedGroup("DOMAINNAME\bob"))
Console.WriteLine("Failed to create the protected user. Error: {0}\n", userLockServer.Connection.LastMessage);

◆ AddProtectedUser() [2/2]

bool AddProtectedUser ( string userName)

Add a new protected user.

Parameters
userNameName of the Windows/AD user account. Specify the domain name if the account is from another domain (e.g. DOMAINNAME\UserName).
Returns
True if succeeded, False otherwise.

Example: Create a new protected account for the user Bob

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.AddProtectedGroup("DOMAINNAME\bob"))
Console.WriteLine("Failed to create the protected user. Error: {0}\n", userLockServer.Connection.LastMessage);

◆ AddProtectedOu() [1/2]

bool AddProtectedOu ( string ouDistinguishedName,
out ProtectedAccount paRet )

Add a new protected organizational unit and return it if succeeded.

Parameters
ouDistinguishedNameDistinguished name of the AD organizational unit.
paRetnull if failed, the created instance if succeeded.
Returns
True if succeeded, False otherwise.

Example: Create a new protected account for the OU "OU=MyUsers,DC=domain,DC=local"

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.AddProtectedOu("OU=MyUsers,DC=domain,DC=local"))
Console.WriteLine("Failed to create the protected OU. Error: {0}\n", userLockServer.Connection.LastMessage);
bool AddProtectedOu(string ouDistinguishedName, out ProtectedAccount paRet)
Add a new protected organizational unit and return it if succeeded.
Definition UserLockServerCommon.cs:4931

◆ AddProtectedOu() [2/2]

bool AddProtectedOu ( string ouDistinguishedName)

Add a new protected organizational unit.

Parameters
ouDistinguishedNameDistinguished name of the AD organizational unit.
Returns
True if succeeded, False otherwise.

Example: Create a new protected account for the OU "OU=MyUsers,DC=domain,DC=local"

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.AddProtectedOu("OU=MyUsers,DC=domain,DC=local"))
Console.WriteLine("Failed to create the protected OU. Error: {0}\n", userLockServer.Connection.LastMessage);

◆ AddProtectedAccount() [1/3]

bool AddProtectedAccount ( string accountName,
ProtectedAccountType pat )

Add a protected account by its name and its type.

Parameters
accountNameName of the protected account.
patType of the protected account.
Returns
True if succeeded, False otherwise.

◆ AddProtectedAccount() [2/3]

bool AddProtectedAccount ( string accountName,
ProtectedAccountType pat,
string idPaToCopyCfgFrom )

Add a protected account by its name, its type and another protected account to copy all configuration from.

Parameters
accountNameName of the protected account.
patType of the protected account.
idPaToCopyCfgFromIdentifier of the protected account to copy all configuration from. Note that account types can be different.
Returns
True if succeeded, False otherwise.

◆ AddTemporaryProtectedUser() [1/2]

bool AddTemporaryProtectedUser ( string accountName,
DateTime startDate,
DateTime endDate )

Add a user temporary protected account by its name.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
Returns
True if succeeded, False otherwise.

◆ AddTemporaryProtectedGroup() [1/2]

bool AddTemporaryProtectedGroup ( string accountName,
DateTime startDate,
DateTime endDate )

Add a group temporary protected account by its name.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
Returns
True if succeeded, False otherwise.

◆ AddTemporaryProtectedOu() [1/2]

bool AddTemporaryProtectedOu ( string accountName,
DateTime startDate,
DateTime endDate )

Add a OU temporary protected account by its name.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
Returns
True if succeeded, False otherwise.

◆ AddTemporaryProtectedUser() [2/2]

bool AddTemporaryProtectedUser ( string accountName,
DateTime startDate,
DateTime endDate,
out ProtectedAccount paRet )

Add a user temporary protected account by its name and return it if succeeded.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
paRetnull if failed, the created instance if succeeded.
Returns
True if succeeded, False otherwise.

◆ AddTemporaryProtectedGroup() [2/2]

bool AddTemporaryProtectedGroup ( string accountName,
DateTime startDate,
DateTime endDate,
out ProtectedAccount paRet )

Add a group temporary protected account by its name and return it if succeeded.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
paRetnull if failed, the created instance if succeeded.
Returns
True if succeeded, False otherwise.

◆ AddTemporaryProtectedOu() [2/2]

bool AddTemporaryProtectedOu ( string accountName,
DateTime startDate,
DateTime endDate,
out ProtectedAccount paRet )

Add a OU temporary protected account by its name and return it if succeeded.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
paRetnull if failed, the created instance if succeeded.
Returns
True if succeeded, False otherwise.

◆ AddTemporaryProtectedAccount() [1/5]

bool AddTemporaryProtectedAccount ( string accountName,
DateTime startDate,
DateTime endDate,
ProtectedAccountType pat,
out ProtectedAccount paRet )

Add a temporary protected account by its name, its start and end dates and its type and return it if succeeded.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
patType of the temporary protected account.
paRetnull if failed, the created instance if succeeded.
Returns
True if succeeded, False otherwise.

Example: Add a temporary protected account for the Everyone group from 2014-05-01 00:00:00 to 2014-06-01 00:00:00.

UserLockServer userLockServer = new UserLockServer(".");
$AccountName = 'Everyone'
$AccountType = 'Group'
[DateTime]$StartDate = '2014-05-01 00:00:00'
[DateTime]$EndDate = '2014-06-01 00:00:00'
if (!$UserLockServer.AddTemporaryProtectedAccount($AccountName, $StartDate, $EndDate, $AccountType))
{
Write-Error("Failed to add a $AccountType temporary protected account for $AccountName from $StartDate to $EndDate. Error: `"$($UserLockServer.Connection.LastMessage)`".")
}

◆ AddTemporaryProtectedAccount() [2/5]

bool AddTemporaryProtectedAccount ( string accountName,
DateTime startDate,
DateTime endDate,
ProtectedAccountType pat )

Add a temporary protected account by its name, its start and end dates and its type.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
patType of the temporary protected account.
Returns
True if succeeded, False otherwise.

Example: Add a temporary protected account for the Everyone group from 2014-05-01 00:00:00 to 2014-06-01 00:00:00.

UserLockServer userLockServer = new UserLockServer(".");
$AccountName = 'Everyone'
$AccountType = 'Group'
[DateTime]$StartDate = '2014-05-01 00:00:00'
[DateTime]$EndDate = '2014-06-01 00:00:00'
if (!$UserLockServer.AddTemporaryProtectedAccount($AccountName, $StartDate, $EndDate, $AccountType))
{
Write-Error("Failed to add a $AccountType temporary protected account for $AccountName from $StartDate to $EndDate. Error: `"$($UserLockServer.Connection.LastMessage)`".")
}

◆ AddTemporaryProtectedAccount() [3/5]

bool AddTemporaryProtectedAccount ( string accountName,
DateTime startDate,
DateTime endDate,
ProtectedAccountType pat,
bool bCopyCfgFromPrmPa )

Add a temporary protected account by its name, its start and end dates, its type and a bool to copy the configuration of the corresponding permanent protected account if any.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
patType of the temporary protected account.
bCopyCfgFromPrmPaIf True, copy the configuration of the corresponding permanent protected account if any.
Returns
True if succeeded, False otherwise.

◆ AddTemporaryProtectedAccount() [4/5]

bool AddTemporaryProtectedAccount ( string accountName,
DateTime startDate,
DateTime endDate,
ProtectedAccountType pat,
string idPaToCopyCfgFrom )

Add a temporary protected account by its name, its start and end dates, its type and another protected account to copy all configuration from.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
patType of the temporary protected account.
idPaToCopyCfgFromIdentifier of the protected account to copy all configuration from. Note that account types can be different.
Returns
True if succeeded, False otherwise.

◆ AddProtectedAccount() [3/3]

bool AddProtectedAccount ( string accountName,
ProtectedAccountType pat,
string idPaToCopyCfgFrom,
out ProtectedAccount paRet )

Adds a permanent protected account with its name, the type of account, the ID of another protected account from which the entire configuration is copied, returns if it was successful, and if so returns created object.

Parameters
accountNameAccount name.
patAccount type.
idPaToCopyCfgFromThe ID of another protected account from which the entire configuration is copied. Note that account types may be different.
paRetThe instance created on success, null otherwise.
Returns
True if successful, false otherwise.

◆ AddTemporaryProtectedAccount() [5/5]

bool AddTemporaryProtectedAccount ( string accountName,
DateTime startDate,
DateTime endDate,
ProtectedAccountType pat,
string idPaToCopyCfgFrom,
out ProtectedAccount paRet )

Adds a temporary protected account with its name, the start and end dates, the type of account, the ID of another protected account from which the entire configuration is copied, returns if it was successful, and if so returns created object.

Parameters
accountNameAccount name.
startDateStart date of temporary protected account.
endDateEnd date of temporary protected account.
patAccount type.
idPaToCopyCfgFromThe ID of another protected account from which the entire configuration is copied. Note that account types may be different.
paRetThe instance created on success, null otherwise.
Returns
True if successful, false otherwise.

◆ DeleteProtectedAccount() [1/2]

bool DeleteProtectedAccount ( ProtectedAccount protectedAccount)

Delete a protected account.

Parameters
protectedAccountProtected account to delete (Previously retrieved from the server).

◆ DeleteProtectedAccount() [2/2]

bool DeleteProtectedAccount ( string accountName)

Delete a protected account by name.

Parameters
accountNameProtected account to delete.

Example: Delete the protected account for the OU "OU=MyUsers,DC=domain,DC=local"

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.DeleteProtectedAccount("OU=MyUsers,DC=domain,DC=local"))
Console.WriteLine("Failed to delete the protected account. Error: {0}\n", userLockServer.Connection.LastMessage);
bool DeleteProtectedAccount(ProtectedAccount protectedAccount)
Delete a protected account.
Definition UserLockServerCommon.cs:5732

◆ DeleteTemporaryProtectedAccount()

bool DeleteTemporaryProtectedAccount ( string accountName,
DateTime startDate,
DateTime endDate )

Delete a temporary protected account by its name and start and end dates.

Parameters
accountNameName of the temporary protected account.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.
Returns
True if succeeded, False otherwise.

Example: Delete a temporary protected account for the Everyone group from 2014-05-01 00:00:00 to 2014-06-01 00:00:00.

UserLockServer userLockServer = new UserLockServer(".");
$AccountName = 'Everyone'
[DateTime]$StartDate = '2014-05-01 00:00:00'
[DateTime]$EndDate = '2014-06-01 00:00:00'
if (!$UserLockServer.DeleteTemporaryProtectedAccount($AccountName, $StartDate, $EndDate))
{
Write-Error("Failed to delete a temporary protected account for $AccountName from $StartDate to $EndDate. Error: `"$($UserLockServer.Connection.LastMessage)`".")
}

◆ QueryStateAsyncTask()

List< TaskAsyncResult > QueryStateAsyncTask ( ref TaskAsync taskAsync)

Queries the state asynchronous task.

Parameters
taskAsyncThe asynchronous task.
Returns
A list of TaskAsyncResult classes

Example: see LogoffAsync method.


◆ UnsubcribeQueryAsyncTask()

bool UnsubcribeQueryAsyncTask ( TaskAsync taskAsync)

Unsubcribes the query asynchronous task. After this method, it is not possible to query any more the task state, but the asynchronous task is working on.

Parameters
taskAsyncThe asynchronous task.

◆ CancelAsyncTask()

bool CancelAsyncTask ( TaskAsync taskAsync)

Cancels the asynchronous task.

Parameters
taskAsyncThe asynchronous task.

◆ ExecuteOperation()

bool ExecuteOperation ( OperationType operationType,
string[] itemKeys,
IOperationParams operationParams,
IOperationNotify callBackInstance )

Executes one operation.

Parameters
operationTypeType of the operation.
itemKeysThe item keys.
operationParamsThe operation parameters if it's needed.
callBackInstanceThe call back instance if it's needed to be notified of the results. It could be null, in that case there won't be result notifications.
Returns
Exceptions
UserExceptionNo send popup parameters. or No shutdown parameters. or Invalid operation type.

◆ Logoff() [1/2]

bool Logoff ( string session)

Logoff an interactive session.

Parameters
sessionName of the session.

Example: Logoff an interactive session on the machine COMPUTER and with 1 as terminal session number." <code> UserLockServer userLockServer = new UserLockServer("."); if (!userLockServer.Logoff("COMPUTER/1")) Console.WriteLine("Failed to logoff the session. Error: {0}
", userLockServer.Connection.LastMessage);

◆ LogoffAsync() [1/2]

TaskAsync LogoffAsync ( string[] sessions)

Logoffs interactive and IIS sessions in asynchronous way.

Parameters
sessionsName of the sessions.

Example: Logoff interactive sessions on the machines COMPUTER1, COMPUTER2 and COMPUTER3; with 1 as terminal session numbers (and 2 session type, terminal). And query the asynchronous results.

UserLockServer userLockServer = new UserLockServer(".");
UserLockServer.TaskAsync taskAsync = userLockServer.LogoffAsync(new string[3]{"COMPUTER1/1,2","COMPUTER2/1,2","COMPUTER3/1,2"});
if (taskAsync != null)
{
// loop to query asynchronous results
int results = 0;
while (results < 3)
{
List<UserLockServer.TaskAsyncResult> parcial_results = userLockServer.QueryStateAsyncTask(ref taskAsync);
if (parcial_results == null) return;
if (parcial_results.Count > 0)
{
// loop the results
foreach (UserLockServer.TaskAsyncResult result in parcial_results)
{
if (result.State)
Console.WriteLine("Succeeded to logoff the \"{0}\" session.", result.Key);
else
Console.WriteLine("Failed to logoff the \"{0}\" session, reason: \"{1}\".", result.Key, result.Details);
}
results += parcial_results.Count;
// wait to the next query
if(results < 3)
{
if(parcial_results.Count == 1)
Thread.Sleep(2000);
else
Thread.Sleep(1000);
}
}
else if (results < 3) // wait to the next query
Thread.Sleep(3000);
}
// check there is no more results
if( userLockServer.QueryStateAsyncTask(ref _taskAsync).Count == 0 )
Console.WriteLine("Asynchronous task logoff is completed.");
}
Represents an asynchornous task element.
Definition UserLockServerCommon.cs:5876
Represents an asynchronous task result.
Definition UserLockServerCommon.cs:5963
TaskAsync LogoffAsync(string[] sessions)
Logoffs interactive and IIS sessions in asynchronous way.
Definition UserLockServerCommon.cs:6435
List< TaskAsyncResult > QueryStateAsyncTask(ref TaskAsync taskAsync)
Queries the state asynchronous task.
Definition UserLockServerCommon.cs:6037

◆ Logoff() [2/2]

bool Logoff ( Session session)

Logoff an interactive session.

Parameters
sessionInstance of the session retrieved from the server.

Example: Logoff all interactive sessions registered on the UserLock server." <code> UserLockServer userLockServer = new UserLockServer("."); foreach (InteractiveSession userSession in userLockServer.InteractiveSessions) { Console.WriteLine("Closing session {0} of user {1}", userSession.UserName, userSession.SessionKeyName); if (userLockServer.Logoff(userSession)) Console.WriteLine(userLockServer.Connection.LastMessage); else Console.WriteLine("Session successfully closed"); }

◆ LogoffAsync() [2/2]

TaskAsync LogoffAsync ( List< Session > sessions)

Logoffs interactive and IIS sessions in asynchronous way.

Parameters
sessionsSession instances retrieved from the server.

Example: Logoff all interactive sessions registered on the UserLock server. And query the asynchronous results.

UserLockServer userLockServer = new UserLockServer(".");
List<Session> sessions = userLockServer.AllSessions.FindAll(delegate(Session ses)
{
return ses.SessionType == SessionType.Interactive;
});
UserLockServer.TaskAsync taskAsync = userLockServer.LogoffAsync(sessions);
if (taskAsync != null)
{
// loop to query asynchronous results
int results = 0;
while (results < sessions.Count)
{
List<UserLockServer.TaskAsyncResult> parcial_results = userLockServer.QueryStateAsyncTask(ref taskAsync);
if (parcial_results == null) return;
if (parcial_results.Count > 0)
{
// loop the results
foreach (UserLockServer.TaskAsyncResult result in parcial_results)
{
if (result.State)
Console.WriteLine("Succeeded to logoff the \"{0}\" session.", result.Key);
else
Console.WriteLine("Failed to logoff the \"{0}\" session, reason: \"{1}\".", result.Key, result.Details);
}
results += parcial_results.Count;
// wait to the next query
if(results < sessions.Count)
{
if(parcial_results.Count == 1)
Thread.Sleep(2000);
else
Thread.Sleep(1000);
}
}
else if (results < sessions.Count) // wait to the next query
Thread.Sleep(3000);
}
// check there is no more results
if( userLockServer.QueryStateAsyncTask(ref _taskAsync).Count == 0 )
Console.WriteLine("Asynchronous task logoff is completed.");
}
List< Session > AllSessions
Get all sessions from any kind.
Definition UserLockServerCommon.cs:2324

◆ LogoffIis() [1/2]

bool LogoffIis ( string session)

Logoff a IIS session.

Parameters
sessionKeyName of the session.

Example: Logoff a IIS session on the machine SERVER, for APPPOOL application pool and with 1 as terminal session number." <code> UserLockServer userLockServer = new UserLockServer("."); if (!userLockServer.Logoff("SERVER/APPPOOL/1")) Console.WriteLine("Failed to logoff the session. Error: {0}
", userLockServer.Connection.LastMessage);

◆ LogoffIis() [2/2]

bool LogoffIis ( IisSession session)

Logoff a IIS session.

Parameters
sessionInstance of the session retrieved from the server.

Example: Logoff all IIS sessions registered on the UserLock server." <code> UserLockServer userLockServer = new UserLockServer("."); foreach (IisSession userSession in userLockServer.IisSessions) { Console.WriteLine("Closing session {0} of user {1}", userSession.Name, userSession.KeyName); if (userLockServer.Logoff(userSession)) Console.WriteLine(userLockServer.Connection.LastMessage); else Console.WriteLine("Session successfully closed"); }

◆ Lock() [1/2]

bool Lock ( string session)

Lock an interactive session by specifying the session name.

Parameters
sessionName of the session.

Example: Lock an interactive session on the machine COMPUTER and with 1 as terminal session number." <code> UserLockServer userLockServer = new UserLockServer("."); if (!userLockServer.Lock("COMPUTER/1")) Console.WriteLine("Failed to lock the session. Error: {0}
", userLockServer.Connection.LastMessage);

◆ LockAsync() [1/2]

TaskAsync LockAsync ( string[] sessions)

Locks interactive sessions in asynchronous way.

Parameters
sessionsName of the sessions.

Example: see LogoffAsync method.


◆ Lock() [2/2]

bool Lock ( Session session)

Lock an interactive session.

Parameters
sessionSession instance previously retrieved from the server.

Example: Lock all interactive sessions registered on the UserLock server." <code> UserLockServer userLockServer = new UserLockServer("."); foreach (InteractiveSession userSession in userLockServer.InteractiveSessions) if (!userSession.IsLockedOrDisconnected) { Console.WriteLine("Locking session {0} of user {1}", userSession.UserName, userSession.SessionKeyName); if (userLockServer.Lock(userSession)) Console.WriteLine(userLockServer.Connection.LastMessage); else Console.WriteLine("Session successfully locked"); }

◆ LockAsync() [2/2]

TaskAsync LockAsync ( List< Session > sessions)

Locks interactive sessions in asynchronous way.

Parameters
sessionsSession instances previously retrieved from the server.

Example: see LogoffAsync(List<Session>) method.

◆ Reset() [1/2]

bool Reset ( string session)

Reset an interactive session.

Parameters
sessionName of the session.

Example: Reset an interactive session on the machine COMPUTER and with 1 as terminal session number." <code> UserLockServer userLockServer = new UserLockServer("."); if (!userLockServer.Reset("COMPUTER/1")) Console.WriteLine("Failed to reset the session. Error: {0}
", userLockServer.Connection.LastMessage);

◆ ResetRas()

bool ResetRas ( string session)

Reset a RAS session.

Parameters
sessionName of the session.

Example: Reset a RAS session on the server RASSERVER and with 1 as session number." <code> UserLockServer userLockServer = new UserLockServer("."); if (!userLockServer.Reset("RASSERVER/1")) Console.WriteLine("Failed to reset the session. Error: {0}
", userLockServer.Connection.LastMessage);

◆ ResetIis()

bool ResetIis ( string session)

Reset a IIS session.

Parameters
sessionName of the session.

Example: Reset a IIS session on the server IISSERVER and with 1 as session number." <code> UserLockServer userLockServer = new UserLockServer("."); if (!userLockServer.Reset("IISSERVER/1")) Console.WriteLine("Failed to reset the session. Error: {0}
", userLockServer.Connection.LastMessage);

◆ Reset() [2/2]

bool Reset ( Session session)

Reset a session with a Session instance retrieved from the server.

Parameters
sessionInstance of the session retrieved from the server.

◆ ResetAsync()

TaskAsync ResetAsync ( List< Session > sessions)

Reset sessions with several Session instances retrieved from the server, in asynchronous way.

Parameters
sessionsSession instances retrieved from the server.

Example: Reset all sessions, in asynchronous way. And query the asynchronous results.

UserLockServer userLockServer = new UserLockServer(".");
UserLockServer.TaskAsync taskAsync = userLockServer.ResetAsync(userLockServer.AllSessions);
if (taskAsync != null)
{
// loop to query asynchronous results
int results = 0;
while (results < sessions.Count)
{
List<UserLockServer.TaskAsyncResult> parcial_results = userLockServer.QueryStateAsyncTask(ref taskAsync);
if (parcial_results == null) return;
if (parcial_results.Count > 0)
{
// loop the results
foreach (UserLockServer.TaskAsyncResult result in parcial_results)
{
if (result.State)
Console.WriteLine("Succeeded reset session \"{0}\".", result.Key);
else
Console.WriteLine("Failed reset session \"{0}\", reason: \"{1}\".", result.Key, result.Details);
}
results += parcial_results.Count;
// wait to the next query
if(results < sessions.Count)
{
if(parcial_results.Count == 1)
Thread.Sleep(2000);
else
Thread.Sleep(1000);
}
}
else if (results < sessions.Count) // wait to the next query
Thread.Sleep(3000);
}
// check there is no more results
if( userLockServer.QueryStateAsyncTask(ref _taskAsync).Count == 0 )
Console.WriteLine("Asynchronous task install agent is completed.");
}
TaskAsync ResetAsync(List< Session > sessions)
Reset sessions with several Session instances retrieved from the server, in asynchronous way.
Definition UserLockServerCommon.cs:6773

◆ SendPopup() [1/2]

bool SendPopup ( string session,
string message,
string title )

Send a popup to an interactive session.

Parameters
sessionName of the session.
messageMessage to display to the user.
titleOptional title for the popup. If empty by default "Notification".

Example: Send a popup to the session 1 on the workstation COMPUTER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.SendPopup("COMPUTER/1", "How are you?", "Hello"))
Console.WriteLine("Failed to send the popup. Error: {0}\n", userLockServer.Connection.LastMessage);
bool SendPopup(string session, string message)
Overloaded function to send a popup to an interactive session. See the full version SendPopup(string,...
Definition UserLockServerCommon.cs:6786

◆ SendPopupAsync() [1/2]

TaskAsync SendPopupAsync ( string[] sessions,
string message,
string title )

Sends a popup to several interactive sessions in asynchronous way.

Parameters
sessionsName of the sessions.
messageMessage to display to the user.
titleOptional title for the popup. If empty by default "Notification".

Example: see LogoffAsync method.

◆ SendPopup() [2/2]

bool SendPopup ( Session session,
string message,
string title )

Send a popup to an interactive session with a Session instance retrieved from the server.

Parameters
sessionInstance of the session retrieved from the server.
messageMessage to display to the user.
titleOptional title for the popup. If empty by default "Notification".

◆ SendPopupAsync() [2/2]

TaskAsync SendPopupAsync ( List< Session > sessions,
string message,
string title )

Sends a popup to several interactive sessions in asynchronous way.

Parameters
sessionsSession instances previously retrieved from the server.
messageMessage to display to the user.
titleOptional title for the popup. If empty by default "Notification".

Example: see LogoffAsync(List<Session>) method.

◆ SendPopupToUser()

void SendPopupToUser ( string userName,
string message,
string title )

Send a popup in all sessions of a specific user.

Parameters
userNameUser account name
messageMessage to display to the user.
titleOptional title for the popup. If empty by default "Notification".

◆ SendPopupAsyncToUsers()

TaskAsync SendPopupAsyncToUsers ( string[] userNames,
string message,
string title )

Send a popup in all sessions of several specific users in asynchronous way.

Parameters
userNamesUser account names.
messageMessage to display to the users.
titleOptional title for the popup. If empty by default "Notification".

Example: see LogoffAsync method.

◆ SendPopupToMachine()

void SendPopupToMachine ( string machineName,
string message,
string title )

Send a popup to all sessions on a specific machine.

Parameters
machineNameComputer name
messageMessage to display to users.
titleOptional title for the popup. If empty by default "Notification".

◆ SendPopupAsyncToMachines()

TaskAsync SendPopupAsyncToMachines ( string[] machineNames,
string message,
string title )

Send a popup to all sessions on several specific machines in asynchronous way.

Parameters
machineNamesComputer names.
messageMessage to display to users.
titleOptional title for the popup. If empty by default "Notification".

Example: see LogoffAsync method.

◆ SendPopupToGroup()

void SendPopupToGroup ( string protectedGroupName,
string message,
string title )

Send a popup to all members of a protected group or OU.

Parameters
protectedGroupNameName of the group or distinguished name of the OU
messageMessage to display to users.
titleOptional title for the popup. If empty by default "Notification".

◆ SendPopupAsyncToGroups()

TaskAsync SendPopupAsyncToGroups ( string[] protectedGroupNames,
string message,
string title )

Send a popup to all members of several protected groups or OUs in asynchronous way.

Parameters
protectedGroupNamesNames of the groups or distinguished names of the OUs.
messageMessage to display to users.
titleOptional title for the popup. If empty by default "Notification".

Example: see LogoffAsync method.

◆ InstallAgent() [1/2]

bool InstallAgent ( string computer)

Install the agent for interactive sessions on a workstation or a terminal server.

Parameters
computerComputer name.

Example: Install the agent the workstation COMPUTER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.InstallAgent("COMPUTER"))
Console.WriteLine("Failed to install the agent. Error: {0}\n", userLockServer.Connection.LastMessage);
bool InstallAgent(string computer)
Install the agent for interactive sessions on a workstation or a terminal server.
Definition UserLockServerCommon.cs:7222

◆ InstallRrasAgent()

bool InstallRrasAgent ( string computer)

Install the agent for RRAS sessions on a Microsoft RRAS server (deprecated).

Parameters
computerServer name.

Example: Install the agent the RRAS server RRASSERVER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.InstallRrasAgent("RRASSERVER"))
Console.WriteLine("Failed to install the RRAS agent. Error: {0}\n", userLockServer.Connection.LastMessage);
bool InstallRrasAgent(string computer)
Install the agent for RRAS sessions on a Microsoft RRAS server (deprecated).
Definition UserLockServerCommon.cs:7240

◆ InstallIasAgent()

bool InstallIasAgent ( string computer)

Install the agent for RADIUS sessions on a Microsoft NPS (IAS) server.

Parameters
computerServer name.

Example: Install the agent the NPS server on NPSSERVER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.InstallIasAgent("NPSSERVER"))
Console.WriteLine("Failed to install the NPS agent. Error: {0}\n", userLockServer.Connection.LastMessage);
bool InstallIasAgent(string computer)
Install the agent for RADIUS sessions on a Microsoft NPS (IAS) server.
Definition UserLockServerCommon.cs:7258

◆ InstallIisAgent()

bool InstallIisAgent ( string computer)

Install the agent for IIS sessions on a Microsoft IIS server.

Parameters
computerServer name.

Example: Install the agent the IIS server IISSERVER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.InstallIasAgent("IISSERVER"))
Console.WriteLine("Failed to install the IIS agent. Error: {0}\n", userLockServer.Connection.LastMessage);

◆ InstallAgent() [2/2]

bool InstallAgent ( MachineState machineState)

Install an agent with a MachineState instance retrieved from the server.

Parameters
machineStateMachineState instance retrieved from the server.

◆ InstallAgentAsync()

TaskAsync InstallAgentAsync ( List< MachineState > machineStates)

Install multiple agents asynchronously, specifying MachineState instances retrieved from the UserLock server.

Parameters
machineStatesMachineState instances retrieved from the UserLock server.

Example: Install the agent in all machines that don't have it yet, asynchronously. And query the asynchronous results.

UserLockServer userLockServer = new UserLockServer(".");
if (taskAsync != null)
{
// loop to query asynchronous results
int results = 0;
while (results < sessions.Count)
{
List<UserLockServer.TaskAsyncResult> parcial_results = userLockServer.QueryStateAsyncTask(ref taskAsync);
if (parcial_results == null) return;
if (parcial_results.Count > 0)
{
// loop the results
foreach (UserLockServer.TaskAsyncResult result in parcial_results)
{
if (result.State)
Console.WriteLine("Succeeded agent installation on computer \"{0}\".", result.Key);
else
Console.WriteLine("Failed agent installation on computer \"{0}\", reason: \"{1}\".", result.Key, result.Details);
}
results += parcial_results.Count;
// wait to the next query
if(results < sessions.Count)
{
if(parcial_results.Count == 1)
Thread.Sleep(2000);
else
Thread.Sleep(1000);
}
}
else if (results < sessions.Count) // wait to the next query
Thread.Sleep(3000);
}
// check there is no more results
if( userLockServer.QueryStateAsyncTask(ref _taskAsync).Count == 0 )
Console.WriteLine("Asynchronous task install agent is completed.");
}
TaskAsync InstallAgentAsync(List< MachineState > machineStates)
Install multiple agents asynchronously, specifying MachineState instances retrieved from the UserLock...
Definition UserLockServerCommon.cs:7354
MachineStates AgentDistributionWithoutAgent
Get the agent status for all machines of the protected network zone without the agent installed.
Definition UserLockServerCommon.cs:3117

◆ UninstallAgent() [1/2]

bool UninstallAgent ( string computer)

Uninstall the agent for interactive sessions from a workstation or a terminal server.

Parameters
computerComputer name.

Example: Uninstall the agent from the workstation COMPUTER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.UninstallAgent("COMPUTER"))
Console.WriteLine("Failed to uninstall the agent. Error: {0}\n", userLockServer.Connection.LastMessage);
bool UninstallAgent(string computer)
Uninstall the agent for interactive sessions from a workstation or a terminal server.
Definition UserLockServerCommon.cs:7377

◆ UninstallRrasAgent()

bool UninstallRrasAgent ( string computer)

Uninstall the agent for RRAS sessions from a Microsoft RRAS server (deprecated).

Parameters
computerServer name.

Example: Uninstall the agent from the server RRASSERVER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.UninstallAgent("RRASSERVER"))
Console.WriteLine("Failed to uninstall the agent. Error: {0}\n", userLockServer.Connection.LastMessage);

◆ UninstallIasAgent()

bool UninstallIasAgent ( string computer)

Uninstall the agent for RADIUS sessions from a Microsoft IAS/NPS server.

Parameters
computerServer name.

Example: Uninstall the agent from the server IASSERVER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.UninstallAgent("IASSERVER"))
Console.WriteLine("Failed to uninstall the agent. Error: {0}\n", userLockServer.Connection.LastMessage);

◆ UninstallIisAgent()

bool UninstallIisAgent ( string computer)

Uninstall the agent for IIS sessions from a Microsoft IIS server.

Parameters
computerServer name.

Example: Uninstall the agent from the server IISSERVER.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.UninstallAgent("IISSERVER"))
Console.WriteLine("Failed to uninstall the agent. Error: {0}\n", userLockServer.Connection.LastMessage);

◆ UninstallAgent() [2/2]

bool UninstallAgent ( MachineState machineState)

Uninstall the agent by using a MachineState instance retrieved from the server.

Parameters
machineStateMachineState instance retrieved from the server.

◆ UninstallAgentAsync()

TaskAsync UninstallAgentAsync ( List< MachineState > machineStates)

Uninstall agents with several MachineState instances retrieved from the server, in asynchronous way.

Parameters
machineStatesMachineState instances retrieved from the server.

Example: see InstallAgentAsync method.

◆ Reboot() [1/2]

bool Reboot ( string computer)

Reboot a computer.

Parameters
computerComputer name.

Example: Reboot the computer named COMPUTERNAME

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.Reboot("COMPUTERNAME"))
Console.WriteLine("Failed to reboot the computer. Error: {0}\n", userLockServer.Connection.LastMessage);
bool Reboot(string computer)
Reboot a computer.
Definition UserLockServerCommon.cs:7491

◆ RebootAsync() [1/2]

TaskAsync RebootAsync ( string[] computers)

Reboots several computers in asynchronous way.

Parameters
computersComputer names.

Example: see LogoffAsync method.

◆ Reboot() [2/2]

bool Reboot ( MachineState machineState)

Reboot a computer by specifying a MachineState instance retrieved from the UserLock server.

Parameters
machineStateMachineSate instance retrieved from the server.

◆ RebootAsync() [2/2]

TaskAsync RebootAsync ( List< MachineState > machineStates)

Reboot multiple computers asynchronously, specifying MachineState instances retrieved from the UserLock server.

Parameters
machineStatesMachineSate instances retrieved from the UserLock server.

Example: see InstallAgentAsync method.

◆ WakeUp() [1/2]

bool WakeUp ( string computer)

Wakes up a computer.

Parameters
computerComputer name.

Example: Wake up the computer named COMPUTERNAME

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.WakeUp("COMPUTERNAME"))
Console.WriteLine("Failed to wake up the computer. Error: {0}\n", userLockServer.Connection.LastMessage);
bool WakeUp(string computer)
Wakes up a computer.
Definition UserLockServerCommon.cs:7556

◆ WakeUpAsync() [1/2]

TaskAsync WakeUpAsync ( string[] computers)

Wakes up several computers in asynchronous way.

Parameters
computersComputer names.

Example: see LogoffAsync method.

◆ WakeUp() [2/2]

bool WakeUp ( MachineState machineState)

Wakes up a computer by specifying a MachineState instance retrieved from the UserLock server.

Parameters
machineStateMachineSate instance retrieved from the server.

◆ WakeUpAsync() [2/2]

TaskAsync WakeUpAsync ( List< MachineState > machineStates)

Wake up multiple computers asynchronously, specifying MachineState instances retrieved from the UserLock server.

Parameters
machineStatesMachineSate instances retrieved from the server.

Example: see InstallAgentAsync method.

◆ Shutdown() [1/2]

bool Shutdown ( string computer,
ExecutionMode executionMode,
NotifyMode notifyMode,
double timeOut,
ForceMode forceMode,
string message )

Shutdown a computer.

Parameters
computerComputer name.
executionModeExecution mode. See the enum ExecutionMode.
notifyModeNotify mode. See the enum NotifyMode
timeOutNotification timeout in minutes
forceModeForce applications to close. See the enum ForceMode
messageMessage to display to the user during the notification period

Example: Shutdown the computer named COMPUTERNAME. The shutdown will occur immediately if the computer is a workstation without logged on user or after a timeout of 2 minutes otherwise. If the user as opened documents that need to be saved the shutdown will not be forced.

UserLockServer userLockServer = new UserLockServer(".");
if (!userLockServer.Shutdown("COMPUTERNAME", ExecutionMode.ImmediateIfPossible, NotifyMode.ExecuteAfterTimeout, 2, ForceMode.No, "The computer will be powered off"))
Console.WriteLine("Failed to shutdown the computer. Error: {0}\n", userLockServer.Connection.LastMessage);
bool Shutdown(string computer)
Overloaded function to shutdown a computer. See the full version Shutdown(string, ExecutionMode,...
Definition UserLockServerCommon.cs:7611
ForceMode
Allows to specify if applications will be closed by force during a shutdown. See the Shutdown method ...
Definition UserLockServerCommon.cs:8581
ExecutionMode
Allows to specify the execution mode for a shutdown. See the Shutdown method of the UserLockServer cl...
Definition UserLockServerCommon.cs:8567
NotifyMode
Allows to specify the notify mode for a shutdown. See the Shutdown method of the UserLockServer class...
Definition UserLockServerCommon.cs:8555

◆ ShutdownAsync() [1/3]

TaskAsync ShutdownAsync ( string[] computers,
ExecutionMode executionMode,
NotifyMode notifyMode,
double timeOut,
ForceMode forceMode,
string message )

Shutdowns several computers in asynchronous way.

Parameters
computersComputer names.
executionModeExecution mode. See the enum ExecutionMode.
notifyModeNotify mode. See the enum NotifyMode
timeOutNotification timeout in minutes
forceModeForce applications to close. See the enum ForceMode
messageMessage to display to the user during the notification period

Example: see LogoffAsync method.

◆ Shutdown() [2/2]

bool Shutdown ( MachineState machineState)

Shutdown a computer by specifying a MachineState instance retrieved from the UserLock server.

Parameters
machineStateMachineState instance retrieved from the UserLock server.

◆ ShutdownAsync() [2/3]

TaskAsync ShutdownAsync ( List< MachineState > machineStates)

Overloaded function to shutdown several computers in asynchronous way, by specifying MachineState instances retrieved from the UserLock server. See the full version ShutdownAsync(List<MachineState>, ExecutionMode, NotifyMode, double, ForceMode, string) method.

Parameters
machineStatesList of MachineState instances retrieved from the UserLock server.
Returns
A ISDecisions.UserLockLibrary.UserLockServer.TaskAsync that represents this instance.

◆ ShutdownAsync() [3/3]

TaskAsync ShutdownAsync ( List< MachineState > machineStates,
ExecutionMode executionMode,
NotifyMode notifyMode,
double timeOut,
ForceMode forceMode,
string message )

Shut down multiple computers asynchronously, specifying MachineState instances retrieved from the UserLock server.

Parameters
machineStatesMachineState instances.
executionModeExecution mode. See the enum ExecutionMode.
notifyModeNotify mode. See the enum NotifyMode
timeOutNotification timeout in minutes
forceModeForce applications to close. See the enum ForceMode
messageMessage to display to the user during the notification period

Example: see InstallAgentAsync method.

◆ CreateTable()

bool CreateTable ( )

Create or recreate the UserLogonEvents table where is stored the logon history in the UserLock database.

Returns
True if the operation completed successfully and false otherwise.

◆ CreateTimeIndex()

bool CreateTimeIndex ( )

Creates an index on the EventTime field of the UserLogonEvents table to speed up queries on time frames.

Returns
True if the operation completed successfully and false otherwise.

◆ DeleteTimeIndex()

bool DeleteTimeIndex ( )

Deletes the index on the EventTime field of the UserLogonEvents table.

Returns
True if the operation completed successfully and false otherwise.

◆ ExecuteSqlCommand()

bool ExecuteSqlCommand ( string command)

Executes an SQL command on the UserLock database.

Parameters
commandThe SQL command.
Returns
True if the operation completed successfully and false otherwise.

◆ CompactDatabase()

bool CompactDatabase ( )

Compacts the default UserLock database.

Returns
True if the operation completed successfully and False otherwise.

◆ CleanOldLogons() [1/2]

bool CleanOldLogons ( int days)

Removes logon events older than a specific number of days from the logon history database.

Parameters
daysThe event age limit in days
Returns
True if the operation completed successfully and False otherwise.

◆ CleanOldLogons() [2/2]

bool CleanOldLogons ( DateTime limitDate)

Removes logon events older than a specific date from the logon history database.

Parameters
limitDateThe event date limit.
Returns
True if the operation completed successfully and False otherwise.

◆ CleanAllLogons()

bool CleanAllLogons ( )

Clear all logon events the logon history database.

Returns
True if the operation completed successfully and False otherwise.

◆ UnblockAUser()

void UnblockAUser ( string accountName)

Unblock a specific account with the provided user name.

Parameters
accountNameAccount name which has to be unblocked

◆ BlockAUser()

void BlockAUser ( string accountName,
bool createPermanentPA,
string message,
bool closeAllSessions )

Blocks a specific account with the provided user name (create the related protected account if it doesn't exist).

Parameters
accountNameAccount name which has to be blocked.
createPermanentPAIf set to true, creates a new permanent protected account related to the same user (only if there is no other existing permanent).
messageThe message to display when a blocked user opens a session.
closeAllSessionsIf set to true, all the opened sessions have to be closed after blocking. If the LogoffExceedingSessions property is enabled, this parameter will be considered as true, whatever its value is.

◆ ExistingActiveTemporaryProtectedAccount()

bool ExistingActiveTemporaryProtectedAccount ( string protectedAccountName)

Return True if the provided account name has already an active temporary protected account.

Parameters
protectedAccountNameProtected account name
Returns
True if the provided account name has already an active temporary protected account, otherwise false

◆ CloseAllSessionAfterBlocking()

void CloseAllSessionAfterBlocking ( string protectedAccountName)

Close all the opened sessions of a protected account after this user has been blocked.

Parameters
protectedAccountNameProtected account name of the protected account which has been blocked

◆ UrlDecode()

static void UrlDecode ( ref String sToDecode)
static

URL decode the parameter string according to the HTML URL Encoding Reference (https://www.w3schools.com/TAGS/ref_urlencode.asp).

Parameters
sToDecodeThe parameter string to URL decode in input, and the URL decoded string in output.

◆ UrlEncode()

static void UrlEncode ( ref String s,
bool bEncodeSlash = true,
bool bEncodeComma = false,
bool bEncodePr100 = true,
bool bEncodeColon = true,
bool bEncodeBackS = true,
bool bEncodeAster = true,
bool bEncodeSemiC = true,
bool bEncodeParLe = true,
bool bEncodeParRi = true,
bool bEncodeNewLi = true )
static

URL encode the parameter string according to the HTML URL Encoding Reference (https://www.w3schools.com/TAGS/ref_urlencode.asp).

Parameters
sThe parameter string to URL encode in input, and the URL encoded string in output.
bEncodeSlashIf set to true, all slash characters ('/') in the parameter string will be URL encoded. The default value is true.
bEncodeCommaIf set to true, all comma characters (',') in the parameter string will be URL encoded. The default value is false.
bEncodePr100If set to true, all percent characters ('') in the parameter string will be URL encoded. The default value is true.
bEncodeColonIf set to true, all colon characters (':') in the parameter string will be URL encoded. The default value is true.
bEncodeBackSIf set to true, all backslash characters ('\') in the parameter string will be URL encoded. The default value is true.
bEncodeAsterIf set to true, all asterisk characters ('*') in the parameter string will be URL encoded. The default value is true.
bEncodeSemiCIf set to true, all semicolon characters (';') in the parameter string will be URL encoded. The default value is true.
bEncodeParLeIf set to true, all left parenthesis characters ('(') in the parameter string will be URL encoded. The default value is true.
bEncodeParRiIf set to true, all left parenthesis characters (')') in the parameter string will be URL encoded. The default value is true.
bEncodeNewLiIf set to true, all new line characters ('
') in the parameter string will be URL encoded. The default value is true.

◆ GetOrphanedUsers()

List< ReportedUser > GetOrphanedUsers ( )

Get all orphaned users.

Returns
A collection containing all orphaned users.

◆ ResetMFAKey()

bool ResetMFAKey ( string UserName)

Resets the MFA key for the provided user account name.

Parameters
UserNameUser account name.
Returns
true if reset was successful, false otherwise.

◆ DisableMFA()

void DisableMFA ( string accountName,
DateTime startDate,
DateTime endDate )

Disable MFA for the provided account name.

Parameters
accountNameAccount name.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.

◆ DisableMFAAndResetMFAHelpMeStatus()

void DisableMFAAndResetMFAHelpMeStatus ( string accountName,
DateTime startDate,
DateTime endDate )

Disable MFA and reset the MFA help me status for the provided account name.

Parameters
accountNameAccount name.
startDateStart date of the temporary protected account.
endDateEnd date of the temporary protected account.

◆ RestartServiceAsync()

TaskAsync RestartServiceAsync ( string serviceName,
string computerName = "." )

Restart service on computer.

Parameters
serviceName
computerName
Returns

◆ CanTestMfaUrl()

bool CanTestMfaUrl ( )

Checks if the MFA IIS URL is relative or not.

Returns
true
if it is relative, false otherwise.

◆ CombineUrl()

static string CombineUrl ( string baseUrl,
string pathToAdd )
static
Parameters
baseUrl
pathToAdd
Returns

◆ TestMfaUrl()

bool TestMfaUrl ( out string errorMessage,
string publicUrl = "",
string privateUrl = "" )

Tests the MFA URL.

Parameters
errorMessage[OUT] The error message if any.
publicUrl[IN] The public URL.
privateUrl[IN] The private URL.
Returns
True if successful, false otherwise.

◆ GetEnabledPolicies()

IList< EnabledPolicies > GetEnabledPolicies ( )

Retrive a list of all enabled policies on the server.

Returns

◆ GetInitialAccessPointPolicy()

InitialAccessPointPolicy GetInitialAccessPointPolicy ( string paIdentifier)

Get the InitialAccessPointPolicy for paIdentifier

Parameters
paIdentifierThe account identifier.
Returns
The InitialAccessPointPolicy object, or null if don't exist

◆ GetTemporaryInitialAccessPointPolicy()

InitialAccessPointPolicy GetTemporaryInitialAccessPointPolicy ( string accountName,
DateTime startDate,
DateTime endDate )

Get a temporary InitialAccessPointPolicy for accountName.

Parameters
accountNameThe account name
startDateThe start date
endDateThe end date
Returns
The InitialAccessPointPolicy object, or null if don't exist

◆ AddInitialAccessPointPolicyToGroup() [1/2]

bool AddInitialAccessPointPolicyToGroup ( string groupName,
out InitialAccessPointPolicy policyRet )

Add a initial access point policy to a group.

Parameters
groupNameThe group name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddInitialAccessPointPolicyToGroup() [2/2]

bool AddInitialAccessPointPolicyToGroup ( string groupName)

Add a initial access point policy to a group.

Parameters
groupNameThe group name
Returns
True if succeeded, false otherwhise

◆ AddInitialAccessPointPolicyToUser() [1/2]

bool AddInitialAccessPointPolicyToUser ( string userName,
out InitialAccessPointPolicy policyRet )

Add a initial access point policy to a User.

Parameters
userNameThe user name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddInitialAccessPointPolicyToUser() [2/2]

bool AddInitialAccessPointPolicyToUser ( string userName)

Add a initial access point policy to a User.

Parameters
userNameThe user name
Returns
True if succeeded, false otherwhise

◆ AddInitialAccessPointPolicyToOu() [1/2]

bool AddInitialAccessPointPolicyToOu ( string ouName,
out InitialAccessPointPolicy policyRet )

Add a initial access point policy to a OU.

Parameters
ouNamethe ou name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddInitialAccessPointPolicyToOu() [2/2]

bool AddInitialAccessPointPolicyToOu ( string ouName)

Add a initial access point policy to a OU.

Parameters
ouNamethe ou name
Returns
True if succeeded, false otherwhise

◆ AddTemporaryInitialAccessPointPolicyToOu() [1/2]

bool AddTemporaryInitialAccessPointPolicyToOu ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary initial access point policy to a OU.

Parameters
accountNamethe ou name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporaryInitialAccessPointPolicyToOu() [2/2]

bool AddTemporaryInitialAccessPointPolicyToOu ( string accountName,
DateTime startDate,
DateTime endDate,
out InitialAccessPointPolicy policyRet )

Add a temporary initial access point policy to a OU.

Parameters
accountNamethe ou name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddTemporaryInitialAccessPointPolicyToGroup() [1/2]

bool AddTemporaryInitialAccessPointPolicyToGroup ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary initial access point policy to a Group.

Parameters
accountNamethe group name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporaryInitialAccessPointPolicyToGroup() [2/2]

bool AddTemporaryInitialAccessPointPolicyToGroup ( string accountName,
DateTime startDate,
DateTime endDate,
out InitialAccessPointPolicy policyRet )

Add a temporary initial access point policy to a Group.

Parameters
accountNamethe group name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddTemporaryInitialAccessPointPolicyToUser() [1/2]

bool AddTemporaryInitialAccessPointPolicyToUser ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary initial access point policy to a User.

Parameters
accountNamethe user name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporaryInitialAccessPointPolicyToUser() [2/2]

bool AddTemporaryInitialAccessPointPolicyToUser ( string accountName,
DateTime startDate,
DateTime endDate,
out InitialAccessPointPolicy policyRet )

Add a temporary initial access point policy to a User.

Parameters
accountNamethe user name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ GetSessionLimitPolicy()

SessionLimitPolicy GetSessionLimitPolicy ( string paIdentifier)

Get the SessionLimitPolicy for paIdentifier

Parameters
paIdentifierThe account identifier.
Returns
The SessionLimitPolicy object, or null if don't exist

◆ GetTemporarySessionLimitPolicy()

SessionLimitPolicy GetTemporarySessionLimitPolicy ( string accountName,
DateTime startDate,
DateTime endDate )

Get a temporary SessionLimitPolicy for accountName.

Parameters
accountNameThe account name
startDateThe start date
endDateThe end date
Returns
The SessionLimitPolicy object, or null if don't exist

◆ AddSessionLimitPolicyToGroup() [1/2]

bool AddSessionLimitPolicyToGroup ( string groupName,
out SessionLimitPolicy policyRet )

Add a Session Limit policy to a group.

Parameters
groupNameThe group name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddSessionLimitPolicyToGroup() [2/2]

bool AddSessionLimitPolicyToGroup ( string groupName)

Add a Session Limit policy to a group.

Parameters
groupNameThe group name
Returns
True if succeeded, false otherwhise

◆ AddSessionLimitPolicyToUser() [1/2]

bool AddSessionLimitPolicyToUser ( string userName,
out SessionLimitPolicy policyRet )

Add a Session Limit policy to a User.

Parameters
userNameThe user name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddSessionLimitPolicyToUser() [2/2]

bool AddSessionLimitPolicyToUser ( string userName)

Add a Session Limit policy to a User.

Parameters
userNameThe user name
Returns
True if succeeded, false otherwhise

◆ AddSessionLimitPolicyToOu() [1/2]

bool AddSessionLimitPolicyToOu ( string ouName,
out SessionLimitPolicy policyRet )

Add a Session Limit policy to a OU.

Parameters
ouNamethe ou name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddSessionLimitPolicyToOu() [2/2]

bool AddSessionLimitPolicyToOu ( string ouName)

Add a Session Limit policy to a OU.

Parameters
ouNamethe ou name
Returns
True if succeeded, false otherwhise

◆ AddTemporarySessionLimitPolicyToOu() [1/2]

bool AddTemporarySessionLimitPolicyToOu ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary Session Limit policy to a OU.

Parameters
accountNamethe ou name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporarySessionLimitPolicyToOu() [2/2]

bool AddTemporarySessionLimitPolicyToOu ( string accountName,
DateTime startDate,
DateTime endDate,
out SessionLimitPolicy policyRet )

Add a temporary Session Limit policy to a OU.

Parameters
accountNamethe ou name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddTemporarySessionLimitPolicyToGroup() [1/2]

bool AddTemporarySessionLimitPolicyToGroup ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary Session Limit policy to a Group.

Parameters
accountNamethe group name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporarySessionLimitPolicyToGroup() [2/2]

bool AddTemporarySessionLimitPolicyToGroup ( string accountName,
DateTime startDate,
DateTime endDate,
out SessionLimitPolicy policyRet )

Add a temporary Session Limit policy to a Group.

Parameters
accountNamethe group name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddTemporarySessionLimitPolicyToUser() [1/2]

bool AddTemporarySessionLimitPolicyToUser ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary Session Limit policy to a User.

Parameters
accountNamethe user name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporarySessionLimitPolicyToUser() [2/2]

bool AddTemporarySessionLimitPolicyToUser ( string accountName,
DateTime startDate,
DateTime endDate,
out SessionLimitPolicy policyRet )

Add a temporary Session Limit policy to a User.

Parameters
accountNamethe user name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ GetWorkstationPolicy()

WorkstationPolicy GetWorkstationPolicy ( string paIdentifier)

Get the WorkstationPolicy for paIdentifier

Parameters
paIdentifierThe account identifier.
Returns
The WorkstationPolicy object, or null if don't exist

◆ GetTemporaryWorkstationPolicy()

WorkstationPolicy GetTemporaryWorkstationPolicy ( string accountName,
DateTime startDate,
DateTime endDate )

Get a temporary WorkstationPolicy for accountName.

Parameters
accountNameThe account name
startDateThe start date
endDateThe end date
Returns
The WorkstationPolicy object, or null if don't exist

◆ AddWorkstationPolicyToGroup() [1/2]

bool AddWorkstationPolicyToGroup ( string groupName,
out WorkstationPolicy policyRet )

Add a Workstation restrictions policy to a group.

Parameters
groupNameThe group name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddWorkstationPolicyToGroup() [2/2]

bool AddWorkstationPolicyToGroup ( string groupName)

Add a Workstation restrictions policy to a group.

Parameters
groupNameThe group name
Returns
True if succeeded, false otherwhise

◆ AddWorkstationPolicyToUser() [1/2]

bool AddWorkstationPolicyToUser ( string userName,
out WorkstationPolicy policyRet )

Add a Workstation restrictions policy to a User.

Parameters
userNameThe user name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddWorkstationPolicyToUser() [2/2]

bool AddWorkstationPolicyToUser ( string userName)

Add a Workstation restrictions policy to a User.

Parameters
userNameThe user name
Returns
True if succeeded, false otherwhise

◆ AddWorkstationPolicyToOu() [1/2]

bool AddWorkstationPolicyToOu ( string ouName,
out WorkstationPolicy policyRet )

Add a Workstation restrictions policy to a OU.

Parameters
ouNamethe ou name
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddWorkstationPolicyToOu() [2/2]

bool AddWorkstationPolicyToOu ( string ouName)

Add a Workstation restrictions policy to a OU.

Parameters
ouNamethe ou name
Returns
True if succeeded, false otherwhise

◆ AddTemporaryWorkstationPolicyToOu() [1/2]

bool AddTemporaryWorkstationPolicyToOu ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary Workstation restrictions policy to a OU.

Parameters
accountNamethe ou name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporaryWorkstationPolicyToOu() [2/2]

bool AddTemporaryWorkstationPolicyToOu ( string accountName,
DateTime startDate,
DateTime endDate,
out WorkstationPolicy policyRet )

Add a temporary Workstation restrictions policy to a OU.

Parameters
accountNamethe ou name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddTemporaryWorkstationPolicyToGroup() [1/2]

bool AddTemporaryWorkstationPolicyToGroup ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary Workstation restrictions policy to a Group.

Parameters
accountNamethe group name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporaryWorkstationPolicyToGroup() [2/2]

bool AddTemporaryWorkstationPolicyToGroup ( string accountName,
DateTime startDate,
DateTime endDate,
out WorkstationPolicy policyRet )

Add a temporary Workstation restrictions policy to a Group.

Parameters
accountNamethe group name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

◆ AddTemporaryWorkstationPolicyToUser() [1/2]

bool AddTemporaryWorkstationPolicyToUser ( string accountName,
DateTime startDate,
DateTime endDate )

Add a temporary Workstation restrictions policy to a User.

Parameters
accountNamethe user name
startDatestart date
endDateend date
Returns
True if succeeded, false otherwhise

◆ AddTemporaryWorkstationPolicyToUser() [2/2]

bool AddTemporaryWorkstationPolicyToUser ( string accountName,
DateTime startDate,
DateTime endDate,
out WorkstationPolicy policyRet )

Add a temporary Workstation restrictions policy to a User.

Parameters
accountNamethe user name
startDatestart date
endDateend date
policyRetnull if failed, the created instance if succeeded
Returns
True if succeeded, false otherwhise

Property Documentation

◆ ProtectedAccounts

Get the list of all protected accounts configured on the UserLock server.

Example: List all protected accounts on the UserLock server

UserLockServer userLockServer = new UserLockServer(".")
foreach (ProtectedAccount protectedAccount in userLockServer.ProtectedAccounts)
Console.WriteLine("Name: {0,15} Type: {1,10} Allowed interactive sessions: {2,4}",
protectedAccount.AccountName, protectedAccount.Type, protectedAccount.NbConcurrentLogins);
List of protected accounts. See the class ProtectedAccount and see the property ProtectedAccounts of ...
Definition ProtectedAccount.cs:2765

◆ Messages

Get the list of all customizable message from the UserLock server.

UserLockServer userLockServer = new UserLockServer(".")
foreach (Message message in userLockServer.Messages)
Console.WriteLine("Message {0} = {1}", message.MessageId, message.Value);
Customizable message.
Definition Message.cs:21
List of customizable messages. See the class Message.
Definition Message.cs:218

◆ InteractiveSessions

List<InteractiveSession> InteractiveSessions
get

Get all interactive sessions.

Example: Send a popup to all opened interactive sessions

UserLockServer userLockServer = new UserLockServer(".")
foreach (Session session in userLockServer.InteractiveSessions)
userLockServer.SendPopup(session, "Warning, something is going on!", "Alert");

◆ ReportedMachinesSimple

List<ReportedMachine> ReportedMachinesSimple
get

List of workstations with only the number of sessions on each workstation. User and session information is not provided. This is a public command. Anyone can get this information.

Example: Power off all workstations without any session on them

UserLockServer userLockServer = new UserLockServer(".")
ReportedMachines reportedWorkstations = userLockServer.ReportedMachinesSimple;
foreach (ReportedMachine reportedWorkstation in reportedWorkstations)
if (reportedWorkstation.SessionCount == 0)
userLockServer.Shutdown(reportedWorkstation.MachineName, ExecutionMode.ImmediateIfPossible, NotifyMode.PopupPeriod, 5, ForceMode.No, "This workstation will be powered off");

◆ AgentDistributionWithoutAgent

MachineStates AgentDistributionWithoutAgent
get

Get the agent status for all machines of the protected network zone without the agent installed.

Example: Install the desktop agent on any workstation without the agent

UserLockServer userLockServer = new UserLockServer(".");
foreach (MachineState machineState in userLockServer.AgentDistributionWithoutAgent)
if (machineState.IsWorkstation)
userLockServer.InstallAgent(machineState);
State of a machine in the protected network zone. This is an element of a MachineStates list.
Definition MachineStatus.cs:16
bool IsWorkstation
True if the computer is a workstation, False otherwise.
Definition MachineStatus.cs:175

◆ AgentDistributionProperties

Get the agent distribution properties of the UserLock server. See the class AgentDistributionProperties for more information.

Example: Start the automatic deployment mode

UserLockServer userLockServer = new UserLockServer(".");
AgentDistributionProperties agentDistributionProperties = userLockServer.AgentDistributionProperties;
agentDistributionProperties.DeployMode = true; // The agent will be installed
agentDistributionProperties.AutoMode = true; // The automatic deployment mode is enabled
agentDistributionProperties.SetInfo(AgentDistributionProperties.PropertyList.Deployer); // Upload deployer properties
Agent distribution properties. See the property AgentDistributionProperties of the UserLockServer cla...
Definition AgentDistributionProperties.cs:25
override void SetInfo()
Upload all properties to the UserLock server.
Definition AgentDistributionProperties.cs:87
PropertyList
Agent distribution property list. See the method SetInfo of the AgentDistributionProperties class.
Definition AgentDistributionProperties.cs:186
AgentDistributionProperties AgentDistributionProperties
Get the agent distribution properties of the UserLock server. See the class AgentDistributionProperti...
Definition UserLockServerCommon.cs:3168