Page 1 of 1
Command "cd \\server /user:name" doesn't disconnec
Posted: 2010-04-23, 14:30 UTC
by bfu
I use this command in Directory menu (Ctrl+D) this way:
The first item is "cd \\server" and it connects me to the server with my current TC process account name.
The second one is "cd \\server /user:adminuser" and if connection currently doesn't exist, it queries the password for server\adminuser account (there are no domain servers/AD in our network) and then connects me.
But if connection already exists, there is no password query and I stay connected with my current login name.
So, to force the change of the session user I must first manually execute commands "net use \\server\IPC$ /delete", "net use \\server\share1 /delete", "net use \\server\share2 /delete" etc. and then do "cd \\server" or "cd \\server /user:adminuser" (via Directory menu). I have tried this on several combinations of client/server computers (versions of Windows).
I think, that if current session user <> /user parameter, the command SHOULD disconnect and then query for password or display error that it cannot disconnect. And finally, it WOULD be nice to have some comfortable way to do manual disconnection from the given server.
Posted: 2010-04-23, 14:48 UTC
by karlchen
Hello, bfu.
I disagree on the point that T.C. should automatically logoff a user. If you run the same
net use commands at the Windows command prompt, Windows will not log a user off automatically, either. Doing so might be dangerous and cause trouble in case that user is running a job using the account across the network.
Kind regards,
Karl
--
P.S.:
What you write qualifies as a feature request, but not as a bug report. - A bug means that a programme promises to perform an action, but does not do so. Nowhere T.C. promises to perform the actions which you describe.
<corrected>
Incorrect.

The history.txt entry dated 05.01.2010 does state T.C. will autmatically diconnect a connected user. See bfu's post below and the history.txt file of course.
<corrected>
Posted: 2010-04-23, 15:02 UTC
by Clo
Moderator message
Thread moved to “TC7.55 Suggestions” since there is no bug, but the feature is missing…
Clo, moderator.
Posted: 2010-04-26, 08:37 UTC
by bfu
Hi,
the only reason I reported the TC behaviour as a bug is this item in history.txt:
--
05.01.10 Added: "cd" command in button bar and user menu now accepts parameter /user:, e.g. cd \\server\share /user:username (tries to auto-disconnect first if connection with other user name exists)
--
where "disconnection attempt" is mentioned. If this can be dangerous let's do it TC7.55 Suggestion, I agree.
Posted: 2010-04-26, 11:52 UTC
by karlchen
Hi, bfu.
I'd say: Oops.

You were right and I was wrong, because I had not read the history.txt carefully enough thus missing the quoted statement.
As the T.C. history states T.C. will do what it does not do, you are right: This might suggest a bug then.
(Even though personally I do not like the idea of automatically disconnecting a user.)
Hm, the history says T.C. were going to try and disconnect a user. It does not say what T.C. will do in case that disconnecting fails for some reason. (Some resources kept busy and locked by the connected user e.g.)
Kind regards,
Karl
Posted: 2010-04-26, 16:21 UTC
by ghisler(Author)
TC currently does the following:
1. Call WNetGetUser for the connection to determine the connected user name
2. If the specified user name doesn't contain a backslash \, TC calls GetComputerName, then constructs a name in the form Computername\specified_user
3. If the name returned by WNetGetUser is different, then TC calls WNetCancelConnection(connectionname,false).
4. If WNetCancelConnection returns ERROR_OPEN_FILES or ERROR_DEVICE_IN_USE, TC beeps and doesn't try to connect with new user name
I assume that the connection is still being used, so TC cannot disconnect it.
Posted: 2010-04-27, 09:44 UTC
by bfu
Thank you for your quick response and description. It is (my) marginal problem (with simple workaround - net use /delete) so don't bother trying to resolve this anymore

I only wanted to notice the little discrepancy that TC is not able to disconnect while (possibly multiple) net use /delete succeeds and then I am able to reconnect with different name.
Posted: 2010-04-27, 15:41 UTC
by ghisler(Author)
I assume that net use /delete calls WNetCancelConnection(connectionname,true).
As described on MSDN:
http://msdn.microsoft.com/en-us/library/aa385423%28VS.85%29.aspx
The second parameter "force" tells the function to remove the share even if it is currently in use. Currently I prefer not to do that. Maybe it helps to switch to a local drive before trying to make the connection in TC?
Posted: 2010-05-11, 14:53 UTC
by bfu
To make some conclusion...
First, I don't know the background in the form of Windows API functions.
The aim is to end the server session that is listed on the server in %SystemRoot%\system32\fsmgmt.msc -> Sessions.
I achieve this by multiple net use \\server\xyz executions on the client. But this is not 100% reliable even if I try not to have any open files/dirs. Empty connection listing of "net use" doesn't ensure that the session doesn't exist.
force user name
Posted: 2012-05-10, 19:31 UTC
by duvik
I have the same problem even now. The command
cd \\server /username
was working but after I reinstalled the PC and installed the newest version of TC this does not work any more. I connect the \\server automatically at Windows startup (connect network drive) but I am unable to connect to this server with a different user name.
Would you have a solution?