开发者

How can I re-use an existing CIFS session or explicitly terminate one programmatically (W2K8 to Netapp)?

开发者 https://www.devze.com 2023-02-08 04:29 出处:网络
I have a program that runs on Windows and scans shares on a Netapp filer over CIFS. When the scanner runs on W2K3 and exits, running \"cifs sessions -c \" on the Netapp filer shows that the session is

I have a program that runs on Windows and scans shares on a Netapp filer over CIFS. When the scanner runs on W2K3 and exits, running "cifs sessions -c " on the Netapp filer shows that the session is gone. When the same scanner runs on W2K8 and exits, the above Netapp command shows the session to be still alive. The scanner application has already exited so there should be no traffic on the session anymore.

What I have done so far: 1) waited for (more than) cifs.idle_timeout number of seconds to see if the session goes away. It does not. 2) analyzed packet-traces for the communication between W2K3->Netapp and W2K8->Netapp. W2K3 trace shows TREE_CONNECT and TREE_DISCONNECT but W2K8 trace shows only the TREE_CONNECT request. I will verify this but I think the TREE_DISCONNECT on W2K3 is followed by a LOGOFF request (which causes the session to end I would believe?). 3) To see how things would look when Netapp is not in the picture -- from the W2K8-client machine, I accessed via windows-explorer \\C$. This causes a TREE_CONNECT request on the wire. Now I closed the explorer window and the W2K3-server machine closed the session even though there was no TREE_DISCONNECT on the wire generated by the W2K8-client.

So seems like Netapp is expecting something that W2K8 is not sending.

Question : Is there a specific API I can use in my scanner application to i) send an explicit LOGOFF SMB request when I am done scanning? ii) or, re-use an existing session b开发者_如何学JAVA/w the W2K8-client and the Netapp filer for a new scan? ii) anyone face this or similar scenarios?

Thanks in advance.


For the API - look at NetUseEnum and NetUseDel.

The disconnect you see is due to idle session (session with no open handles). I'm not sure if this is done by the server (which would indicate a difference between Netapp and Windows) or by the client (your scanner holds an open handle, maybe the current directory, while Explorer closes the handle when you close the window).


I'm not sure what you are trying to accomplish, but it might be easier using NetApp tools/APIs. For a lot of administration tasks the Data ONTAP PowerShell Toolkit can really simplify things:

PS C:\> Connect-NaController fas2040rre1
PS C:\> Get-NaCifsShare
MountPoint                                    ShareName                 Description
----------                                    ---------                 -----------
/etc                                          ETC$                      Remote Administration
/vol/vol0/home                                HOME                      Default Share
                     ... snip ...
/vol/cifs/backups                             backups

And if PowerShell isn't your thing, you can take a look at the Manageability SDK for a Web Services API to C/C++, Java, Perl and .Net. In that case you'd want to look at the cifs-share-list API's (slightly different between 7.x/8.x).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号