Skip to content

"Disconnect Network Drive" Issue in Multiple Sessions of the Same Account #1328

@lanopk

Description

@lanopk

I would like to offer my opinion regarding an issue where "Disconnect Network Drive" appears in different sessions when a single account has multiple sessions, such as on Windows Server.

NP only checks for session IDs that are -1 or match the session ID in dokanMountPointInfo.

This becomes an issue when the same account has multiple sessions, as is the case with Windows Server.

Therefore, I would like to suggest adding a feature to determine if the sessions belong to the same account when they differ.

I have tested this and it works correctly.

The code is as follows.
`
#include <wtsapi32.h>
#pragma comment(lib, "wtsapi32.lib")

BOOL IsSameUser(DWORD sessionID1, DWORD sessionID2) {
LPTSTR userName1 = NULL, domain1 = NULL;
LPTSTR userName2 = NULL, domain2 = NULL;
DWORD bytesReturned = 0;
BOOL isSame = FALSE;

WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionID1, WTSUserName,
&userName1, &bytesReturned);
WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionID1,
WTSDomainName, &domain1, &bytesReturned);

WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionID2, WTSUserName,
&userName2, &bytesReturned);
WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, sessionID2,
WTSDomainName, &domain2, &bytesReturned);

// 둘 다 사용자 정보가 있고, 일치하는지 확인
if (userName1 && userName2 && domain1 && domain2) {
if (_tcscmp(userName1, userName2) == 0 && _tcscmp(domain1, domain2) == 0) {
isSame = TRUE;
}
}

WTSFreeMemory(userName1);
WTSFreeMemory(domain1);
WTSFreeMemory(userName2);
WTSFreeMemory(domain2);

return isSame;
}`

In the NPGetConnection function :

if (dokanMountPointInfo[i].SessionId == -1 ||
((dokanMountPointInfo[i].SessionId == currentSessionId) &&
wcscmp(dokanMountPointInfo[i].MountPoint, dosDevice) == 0) || IsSameUser(currentSessionId, dokanMountPointInfo[i].SessionId)) {
...

In the NPEnumResource function :
if (-1 != dokanMountPointInfo[pCtx->index].SessionId &&
sessionId != dokanMountPointInfo[pCtx->index].SessionId && IsSameUser(sessionId, dokanMountPointInfo[pCtx->index].SessionId) == FALSE) {
..

I would appreciate it if you could review this and implement it if it is a good direction.
Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions