The functions in the Session category control network sessions established between clients and servers.
|
Function |
Description |
|
Ends a session between a client and a server. |
|
|
This function is the same as NetSessionDel except that it is RPC-based. |
|
|
Provides information on all current sessions to a server. |
|
|
This function is the same as NetSessionEnum except that it uses 32-bit data structures, is RPC-based, and is resumable. |
|
|
Retrieves information about a specified client/server session. |
|
|
This function is the same as NetSessionGetInfo except that it uses 32-bit data structures and is RPC-based. |
A session is a link between a client and a server. A client begins a session with a server the first time it requests to connect to a shared resource on the server. Any further connections from the client to the other shared resources on the same server do not create another session; multiple connections can be serviced on one session.
To end a session, deleting all current connections between the client and server, an application calls NetSessionDel or NetSessionDel32. NetSessionEnum and NetSessionEnum32 return information about all sessions established with a server. To obtain information about a specific session, an application calls NetSessionGetInfo or NetSessionGetInfo32.
Per-user information is managed by NetSession APIs through the use of the username parameter. This parameter is necessary to access user-specific information for this session because there can be multiple users per session.
The sLevel parameter controls the level of information that the NetSessionEnum, NetSessionEnum32, NetSessionGetInfo, and NetSessionGetInfo32 functions return.
The session_info_0 data structure that can be returned by NetSessionEnum or NetSessionGetInfo has the following format:
struct session_info_0 {
char * sesi0_cname;
};
Within this structure, sesi0_cname points to an ASCIIZ string containing the computer name of the computer that established the session.
The SESSION_INFO_0 data structure that can be returned by NetSessionEnum32 or NetSessionGetInfo32 has the following format:
typedef struct _SESSION_INFO_0 {
LPTSTR sesi0_cname;
} SESSION_INFO_0, *PSESSION_INFO_0, *LPSESSION_INFO_0;
Within this structure, all parameters are defined in the same way as in the session_info_0 structure.
The session_info_1 data structure that can be returned by NetSessionEnum or NetSessionGetInfo has the following format:
struct session_info_1 {
char * sesi1_cname;
char * sesi1_username;
unsigned short sesi1_num_conns;
unsigned short sesi1_num_opens;
unsigned short sesi1_num_users;
unsigned long sesi1_sess_time;
unsigned long sesi1_idle_time;
unsigned long sesi1_user_flags;
};
Within this structure, the following parameters are defined:
sesi1_cname points to an ASCIIZ string containing the computer name of the computer that established the session.
sesi1_username points to an ASCIIZ string containing the name of the user who established the session.
sesi1_num_conns displays how many connections have been made during the session.
sesi1_num_opens displays how many files, devices, and pipes have been opened during the session.
sesi1_num_users specifies how many users have made connections via the session.
sesi1_sess_time specifies how many seconds a session has been active.
sesi1_idle_time specifies how many seconds a session has been idle.
sesi1_user_flags describes how the user established the session.
The bit mask for sesi1_user_flags is defined in the shares.h file, as follows:
|
Manifest |
Value |
Meaning |
|
SESS_GUEST |
1 |
sesi1_username established the session using a guest account. |
|
SESS_NOENCRYPTION |
2 |
sesi1_username established the session without using password encryption. |
The SESSION_INFO_1 data structure that can be returned by NetSessionEnum32 or NetSessionGetInfo32 has the following format:
typedef struct _SESSION_INFO_1 {
LPTSTR sesi1_cname;
LPTSTR sesi1_username;
DWORD sesi1_num_opens;
DWORD sesi1_time;
DWORD sesi1_idle_time;
DWORD sesi1__flags;
} SESSION_INFO_1, *PSESSION_INFO_1, *LPSESSION_INFO_1;
Within this structure, all parameters are defined in the same way as in the session_info_1 structure.
The session_info_2 data structure that can be used by NetSessionEnum or NetSessionGetInfo has the following format:
struct session_info_2 {
char * sesi2_cname;
char * sesi2_username;
unsigned short sesi2_num_conns;
unsigned short sesi2_num_opens;
unsigned short sesi2_num_users;
unsigned long sesi2_time;
unsigned long sesi2_idle_time;
unsigned long sesi2_user_flags;
char * sesi2_cltype_name;
};
Within this structure, the following parameters are defined:
sesi2_cname to sesi2_user_flags have the same definition as the corresponding fields of the session_info_1 data structure. For a complete description, see Session Information (level 1).
sesi2_cltype_name points to an ASCIIZ string that specifies the type of client that established the session.
These are the defined types for Advanced Server servers:
|
Name |
Type |
|
DOS LM 1.0 |
LAN Manager for MS-DOS 1.0 clients. |
|
DOS LM 2.0 |
LAN Manager for MS-DOS 2.0 clients. |
|
OS/2 LM 1.0 |
LAN Manager for MS-OS/2 1.0 clients. |
|
OS/2 LM 2.0 |
LAN Manager for MS-OS/2 2.0 clients. |
|
NT LANMAN 1.0 |
Windows NT 1.0 clients. |
Sessions from Advanced Server also will appear as OS/2 LM 2.0.
The SESSION_INFO_2 data structure that can be returned by NetSessionEnum32 or NetSessionGetInfo32 has the following format:
typedef struct _SESSION_INFO_2 {
LPTSTR sesi2_cname;
LPTSTR sesi2_username;
DWORD sesi2_num_opens;
DWORD sesi2_time;
DWORD sesi2_idle_time;
DWORD sesi2_flags;
LPTSTR sesi2_cltype_name;
} SESSION_INFO_2, *PSESSION_INFO_2, *LPSESSION_INFO_2;
Within this structure, all parameters are defined in the same way as in the session_info_2 structure.
The session_info_10 data structure that can be returned by NetSessionEnum or NetSessionGetInfo has the following format:
struct session_info_10 {
char * sesi10_cname;
char * sesi10_username;
unsigned long sesi10_time;
unsigned long sesi10_idle_time;
};
Within this structure, the following parameters are defined:
sesi10_cname to sesi10_idle_time have the same definition as the corresponding fields of the session_info_1 data structure. For a complete description, see Session Information (level 1).
The SESSION_INFO_10 data structure that can be returned by NetSessionEnum32 or NetSessionGetInfo32 has the following format:
typedef struct _SESSION_INFO_10 {
LPTSTR sesi10_cname;
LPTSTR sesi10_username;
DWORD sesi10_time;
DWORD sesi10_idle_time;
} SESSION_INFO_10, *PSESSION_INFO_10, *LPSESSION_INFO_10;
Within this structure, all parameters are defined in the same way as in the session_info_10 structure.