# IServer

Description:

`IServer` is the central entry point of the library. It is the only creatable object in the hierarchy for accessing the server.
```cpp
import "OxSvrSpt.idl"
```
Public Methods:
```cpp
HRESULT Login ([in, defaultvalue("")] BSTR User, [in, defaultvalue("")] BSTR Password, [in, defaultvalue("")] BSTR Server, [in, defaultvalue("")] BSTR Port, [in, defaultvalue(pwNotEncrypted)] PasswortTypeEnum PasswortType, [in, defaultvalue()] VARIANT_BOOL DefaultSession, [out, retval] ISession ** ppSession)
HRESULT Connect ([in, defaultvalue("localhost")] BSTR Server, [in, defaultvalue("4000")] BSTR Port)
HRESULT OpenSession ([in, defaultvalue("")] BSTR SessionGUID, [in, defaultvalue("")] BSTR Alias, [out, retval] ISession ** ppSession)
HRESULT LoginBalanced ([in, defaultvalue("")] BSTR User, [in, defaultvalue("")] BSTR Password, [in, defaultvalue("")] BSTR ServerList, [in, defaultvalue(pwNotEncrypted)] PasswortTypeEnum PasswortType, [in, defaultvalue()] VARIANT_BOOL DefaultSession, [out, retval] ISession ** ppSession)
HRESULT LoginGUID ([in, defaultvalue("")] BSTR GUID, [in, defaultvalue("")] BSTR Server, [in, defaultvalue("")] BSTR Port, [in, defaultvalue()] VARIANT_BOOL DefaultSession, [out, retval] ISession ** ppSession)
```
Properties:
```cpp
IProperties Properties [get]
IErrors Errors [get]
```
Documentation of Element Functions:

* `HRESULT Connect ([in, defaultvalue("localhost")] BSTR Server, [in, defaultvalue("4000")] BSTR Port)`

`Connect` establishes a connection to the specified server.

This method currently returns the error `E_NOTIMPL`!

Establishing a connection to a server without logging in is necessary when the server properties are needed. These are made available in the `Properties` after a `Connect`. If these data are not needed, it is not necessary to establish a `Connect` to the server before logging in. The server data can be specified directly during login in this case.

Parameters:

: `Server` (default value is `localhost`) IP address or name of the server to connect to

: `Port` (default value is `4000`) port of the server

* `HRESULT Login ([in, defaultvalue("")] BSTR User, [in, defaultvalue("")] BSTR Password, [in, defaultvalue("")] BSTR Server, [in, defaultvalue("")] BSTR Port, [in, defaultvalue(pwNotEncrypted)] PasswortTypeEnum PasswortType, [in, defaultvalue()] VARIANT_BOOL DefaultSession, [out, retval] ISession ** ppSession)`

`Login` performs a login to the server and returns the corresponding session.

If a connection to a server has already been established via the `Connect` method before calling `Login`, these connection data are used for the `Login` if none are specified.

If both the User and Password parameters are empty or passed with an empty string, an attempt is made to perform the login via automatic `Login`. This must be activated in the enaio® administrator and is not equivalent to NTLMAuthentication.

Parameters:

: `User` user account

: `Password` password of the user account to be used

: `Server` IP address or name of the server to connect to

: `Port` port of the server

: `PasswortType` indicates whether the passed password is already encrypted. If this parameter is not specified, it is assumed that the password was passed unencrypted.

: `DefaultSession` (default value is VARIANT_FALSE) indicates whether this is the session to which the user can later attach using `OpenSession`.

: `ppSession` (VB return parameter) created session for the account.

Exception handling:

`errLoginUnknownUser` (602) The specified user does not exist.

`errLogin3TimesWrong` (603) The third login attempt failed.

`errLoginInvalidPassword` (604) The specified password is incorrect.

`errLoginLocked` (605) The user account is locked.

* `HRESULT LoginBalanced ([in, defaultvalue("")] BSTR User, [in, defaultvalue("")] BSTR Password, [in, defaultvalue("")] BSTR ServerList, [in, defaultvalue(pwNotEncrypted)] PasswortTypeEnum PasswortType, [in, defaultvalue()] VARIANT_BOOL DefaultSession, [out, retval] ISession ** ppSession)`

`LoginBalanced` performs a login to the server and returns the corresponding session.

If both the User and Password parameters are empty or passed with an empty string, an attempt is made to perform the login via automatic `Login`.

Parameters:

: `User` user account

: `Password` password of the user account to be used

: `ServerList` list of servers to which the library should connect. This list has the following format: Server1#Port1#Weight1;Server2#Port2#Weight2#;Server3#Port3#Weight3

: `PasswortType` indicates whether the passed password is already encrypted. If this parameter is not specified, it is assumed that the password was passed unencrypted.

: `DefaultSession` (default value is VARIANT_FALSE) indicates whether this is the session to which the user can later attach using `OpenSession`.

: `ppSession` (VB return parameter) created session for the account.

Exception handling:

`errLoginUnknownUser` (602) The specified user does not exist.

`errLogin3TimesWrong` (603) The third login attempt failed.

`errLoginInvalidPassword` (604) The specified password is incorrect.

`errLoginLocked` (605) The user account is locked.

* `HRESULT LoginGUID ([in, defaultvalue("")] BSTR GUID, [in, defaultvalue("")] BSTR Server, [in, defaultvalue("")] BSTR Port, [in, defaultvalue()] VARIANT_BOOL DefaultSession, [out, retval] ISession ** ppSession)`

`LoginGUID` performs a login with the passed `SessionGUID` to the server and returns the corresponding session.

Using the `SessionGUID`, a connection is established with an existing session on the server.

Parameters:

: `GUID` GUID of the server session with which the `Session` object should work

: `Server` IP address or name of the server to connect to

: `Port` port of the server

: `DefaultSession` (default value is VARIANT_FALSE) indicates whether this is the session to which the user can later attach using `OpenSession`

: `ppSession` (VB return parameter) created session for the account

Exception handling:

`errLoginLocked` (605) The user account is locked.

* `HRESULT OpenSession ([in, defaultvalue("")] BSTR SessionGUID, [in, defaultvalue("")] BSTR Alias, [out, retval] ISession ** ppSession)`

`OpenSession` creates a new `Session` object and connects it to the `DefaultSession`.

Parameters:

: `SessionGUID` GUID of the existing session with which the connection should be established

: `Alias` arbitrary name for the call to assign errors or state

: `ppSession` (VB return parameter) created session for the account

Documentation of Properties:

* `IErrors Errors [get]`

`Errors` returns the error collection with the errors of the server access.

Parameters:

: `pVal` (VB return value) error collection

* `IProperties Properties [get]`

`Properties` returns the collection with the server properties.

Currently, the following properties are set by the OxSvrSpt library when creating the server object:

TempDir:

Contains the temporary directory where the files of the file parameters should be stored. This is initialized with the user's temporary directory.

NotifyNeeded:

Initialized with 0.

If the value is set to a value unequal to 0 (or VARIANT_FALSE), support for notifications is activated. Then it is possible to process notifications via the event interface of the server and session objects.

The specified identifiers correspond to the parameter names.

Parameters:

: `pVal` (VB return parameter) `IProperties` interface
