Best practice for logging in to the Management Server from an independent process

Situation

A background plugin reads the Management Server info, and a separate independent process uses it to log in through the MIP SDK.

// Background plugin
var type     = EnvironmentManager.Instance.MasterSite.ServerId.ServerType;
var hostname = EnvironmentManager.Instance.MasterSite.ServerId.ServerHostname;
var port     = EnvironmentManager.Instance.MasterSite.ServerId.Serverport;
var id       = EnvironmentManager.Instance.MasterSite.ServerId.Id;

// Independent process
var managementServerId = new ServerId(type, hostname, port, id);
Uri uri = managementServerId.Uri;

VideoOS.Platform.SDK.Environment.AddServer(false, uri, CredentialCache.DefaultNetworkCredentials);

try
{
    VideoOS.Platform.SDK.Environment.Login(uri);
}
catch (Exception ex)
{
    VideoOS.Platform.SDK.Environment.RemoveServer(uri);
}

Problems found

  1. Login fails when the host is a domain name instead of an IP address.

  2. Login fails when the URI is https.

Request

What is the best practice for this login flow? Specifically:

  • What information is required to minimize login failures (hostname format, scheme, port, certificate, etc.)?

  • Is CredentialCache.DefaultNetworkCredentials the right choice for AddServer?

  • How should we decide the secureOnly value (true / false)?

A sample or documentation link would be very helpful. Thank you!

Hi,

The following documentation might be relevant:
MIP SDK Documentation (This page describes the login process)
MIP SDK Documentation (describes properties used in the login process, among others secureOnly)

Camera Stream Resolution sample is probably good example, please explore it:

1. Regarding the secureOnly parameter:
If I log in with secureOnly = false, does that mean the login will succeed regardless of whether the server uses HTTP or HTTPS? Or do I need to check a specific server-side setting and set this parameter accordingly?

2. Regarding credential types:
How do I determine which credential type to use (XProtect basic user, Windows user, or OAuth token)? Is this something the user is expected to know? Should I ask the user through the UI, or can this information be obtained by querying the ManagementServer by SDK?

  1. Yes, you shouldn’t need to check any of the server side settings. But if the server requires HTTPS and the HTTPS connection from your application to the server cannot be established, then the login will not succeed.

  2. You cannot get the credential type information from the SDK.

Follow-up on 1 (secureOnly parameter):

Is checking “Allow only secure communication” in the DialogLoginForm the same as setting secureOnly to true?

If so, something seems odd. Based on your explanation, setting secureOnly = false should allow login over any type of connection. However, at one customer site, login only succeeded when that toggle was enabled.

Also, how do I configure the server to use HTTPS connections? Is this done in the Management Client? I’d like to set it up in my local environment to test it.

Follow-up on 2 (credential types):

Does the fact that credential type information can’t be obtained through the SDK also apply to server-side background plugins?

Also, will login fail if the credential type differs from what the server expects?

I’m currently using the default credentials(i.e., the current Windows user’s credentials) and haven’t yet seen a case where a different credential type was needed. Is there a particular reason for this? For example, is Milestone VMS designed to always use the default credentials, or something along those lines?

Based on your description, this is not expected behavior.

HTTPS for the Management Server is configured using the Server Configurator, available from the Management Server Manager in the Windows system tray. See the Server Configurator documentation.

Regarding authentication, the application needs to know which authentication method it should use. XProtect supports, among others, Windows users and Basic users. Basic users are created in XProtect, while Windows users are based on Windows/Active Directory accounts. [[doc.milestonesys.com]]Basic user (Security node)

In the Management Client, under Security > Roles, you can see which users and groups have been assigned access.

For a background plug-in hosted by the Event Server, also consider the Windows account under which the Event Server service is running. You can see this in Windows Services under Log On As.

If this is a workgroup installation rather than an Active Directory environment, there are some additional considerations. See the installation for workgroups documentation.

So I would not try to discover the required credential type by first logging in to the Management Server. The process needs an authentication method and credentials that are valid for the particular XProtect installation.

Thank you Bo,

Yes, it is a background plug-in hosted by the Event Server. So, to sum up: if I want the plug-in to work when it is deployed to a user’s machine where we have no prior information about the environment, do I need to provide a preliminary setup step (for example, a form UI) that collects the following information?

  • Which Windows account the Event Server service is running under

  • Whether a Windows account or a Basic user is used to log in to the Management Server

  • If a Basic user is used, which user ID and password should be used

Is that what you mean?

The Event Server service runs under a Windows account. If you make sure that account is a member of the Administrators role in XProtect, it will have the necessary permissions to make calls to the Management Server.

With the default installation, this is normally already configured appropriately. If you have changed the account used by the Event Server service, make sure that account has been added to the appropriate XProtect role.

You can find more information about the Event Server configuration in the XProtect documentation.

Note: As I see it, there’s no reason to gather this information. The Event Server is already logged in, so an Event Server plugin shouldn’t need to handle authentication separately.

(Alternative scenario.) For a standalone application or service, you need to log in separately. Since the application cannot ask the server for a password, I propose that an administrator manually provides the required login credentials during configuration.

Yes, we’re running both an Event Server background plugin and a standalone service. The login failure occurs in the standalone service.

My idea was that if the background plugin could retrieve valid login information and pass it to the standalone service, we wouldn’t need an administrator to enter credentials manually. Is there no way for the background plugin to obtain that information?

No. You can look up users, but you cannot retrieve their passwords from the server. Allowing password retrieval would pose a security risk.