Introduction
The UserLock API allows you to write your own .NET applications that will interact directly with the UserLock service. Basically, the UserLock API allows you to programmatically create and configure protected accounts, deploy the agent, close/lock sessions, send pop-ups to users.
Prerequisites
On the computer where you want to create the .NET project:
- .NET 4.7.2.
- Visual Studio 2012 or higher (because .NET 4.7.2 is required by UserLockAPI).
- You need the following UserLock files: "BaseLibrary.dll", "NativeLibrary.dll" (32-bit or 64-bit version) and "UserLockAPI.dll". Here is a way to get these files:
- Log in to your UserLock server.
- Copy the following files to a local folder (e.g. "C:\Temp"):
- "%windir%\Microsoft.NET\assembly\GAC_MSIL\BaseLibrary\v4.0_<UserLock version>__2ebedec025e0906e\BaseLibrary.dll". For example with Userlock 12.2: "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\BaseLibrary\v4.0_12.2.0.0__2ebedec025e0906e\BaseLibrary.dll".
- "%windir%\Microsoft.NET\assembly\GAC_MSIL\UserLockAPI\v4.0_<UserLock version>__2ebedec025e0906e\UserLockAPI.dll". For example with Userlock 12.2: "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\UserLockAPI\v4.0_12.2.0.0__2ebedec025e0906e\UserLockAPI.dll".
- For "NativeLibrary.dll":
- If the architecture used by your .NET application is 64-bit: "%windir%\Microsoft.NET\assembly\GAC_64\NativeLibrary\v4.0_<UserLock version>__2ebedec025e0906e\NativeLibrary.dll". For example with Userlock 12.2: "C:\Windows\Microsoft.NET\assembly\GAC_64\NativeLibrary\v4.0_12.2.0.0__2ebedec025e0906e\NativeLibrary.dll".
- Otherwise: "%windir%\Microsoft.NET\assembly\GAC_64\NativeLibrary\v4.0_<UserLock version>__2ebedec025e0906e\NativeLibrary.dll". For example with Userlock 12.2: "C:\Windows\Microsoft.NET\assembly\GAC_64\NativeLibrary\v4.0_12.2.0.0__2ebedec025e0906e\NativeLibrary.dll".
- We recommend that you keep these files in your executable folder in case UserLock is updated. This way, your executable will always have the correct version of these DLLs and you won't have to rebuild your application from source code when UserLock is updated.
On the computer where you want to run the .NET project:
- You must have the Microsoft Visual C++ Redistributable packages for Visual Studio 2015, 2017, 2019, and 2022:
First steps
- Create your Visual Studio .NET project.
- Add the file "UserLockAPI.dll" as a reference in this project.
- Create an instance of the class UserLockServer. See examples in the constructor of the class.
- Call some methods on the instance of UserLockServer. See the following examples:
Examples