Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing SAN drive
Message
From
30/05/2012 02:41:05
Al Doman (Online)
M3 Enterprises Inc.
North Vancouver, British Columbia, Canada
 
 
To
30/05/2012 01:51:32
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01544730
Message ID:
01544733
Views:
35
This message has been marked as the solution to the initial question of the thread.
>I need to access a SAN drive from an ASP.NET application. As this is not a regular Windows drive, it does not seem to be easy to access the drive with a UNC approach. The drive cannot be shared with an admin drive, such as k$. So, it has a share name such as \\100.100.100.100\Repository\MyDirectory.
>
>As is, I cannot see this drive from the ASP.NET application. The error is:
>
>Unable to gain access to the drive \\100.100.100.100\Repository.
>
>This seems to be related to the fact that I am using the ManagementScope object to try to get the disk space availability of the drive. One of the requirement is to make sure a certain amount of disk space is available before storing some files over there. Is there such a possibility to access the disk space availability of such a drive?
>
>The current method is as:
>
>
>        ' Get the information on a drive by the use of ManagementScope
>        Public Function GetDriveInformationManagementScope() As Boolean
>            Dim lcSQL As String = ""
>            Dim llSuccess As Boolean = False
>            Dim loConnectionOptions As ConnectionOptions = Nothing
>            Dim loManagementObject As ManagementObject = Nothing
>            Dim loManagementObjectCollection As ManagementObjectCollection = Nothing
>            Dim loManagementObjectSearcher As ManagementObjectSearcher = Nothing
>            Dim loManagementScope As ManagementScope = Nothing
>            Dim loObjectQuery As ObjectQuery = Nothing
>
>            ' Reset the values
>            cVolumeSerialNumber = ""
>            nAvailableByte = 0
>            nFreeSpace = 0
>
>            ' Clear the drive
>            If Not ClearDrive() Then
>                Return False
>            End If
>
>            ' Initialization
>            loConnectionOptions = New ConnectionOptions()
>
>            ' Connection information
>            loConnectionOptions.Username = cUsername
>            loConnectionOptions.Password = cPassword
>
>            Try
>
>                ' Use WMI namespace WMI in which management options will be done
>                If cUsername.Length > 0 Then
>                    loManagementScope = New ManagementScope("\\" + cIP + "\root\cimv2", loConnectionOptions)
>                Else
>                    loManagementScope = New ManagementScope("\\" + cIP + "\root\cimv2")
>                End If
>
>                lcSQL = "SELECT * from Win32_LogicalDisk WHERE DriveType=3 AND VolumeName=""" + cVolumeName + """"
>
>                ' The ObjectQuery class represents a management query which returns instances or classes 
>                loObjectQuery = New ObjectQuery(lcSQL)
>
>                ' The ManagementObjectSearcher class allows the extration of an object management collection
>                ' in regards to the query specified during the instantiation by the use of the
>                ' ObjectQuery parameter or directly by a string
>                loManagementObjectSearcher = New ManagementObjectSearcher(loManagementScope, loObjectQuery)
>
>                ' The ManagementObjectCollection represents various object management collections extracted from WMI
>                loManagementObjectCollection = loManagementObjectSearcher.Get()
>
>                ' If we have found it
>                If loManagementObjectSearcher.Get.Count = 1 Then
>
>                    ' For each drive
>                    For Each loManagementObject In loManagementObjectCollection
>                        AddDrive(loManagementObject)
>                    Next
>
>                    ' Make oRows available
>                    oRows = oDataSet.Tables("Temp").Rows()
>
>                    ' Make oRow available
>                    oRow = oRows(0)
>
>                    llSuccess = True
>                Else
>                    cMessage = oApp.StrTran(cUnableToGainAccessToThisDrive, "##Drive##", "\\" + cIP + "\" + cVolumeName)
>                End If
>
>            Catch loError As Exception
>                cMessage = loError.Message + " " + lcSQL
>            End Try
>
>            Return llSuccess
>        End Function
>
>
>Most of the code should be easy to understand. Some of its items are related to the framework. But, the main Management Scope design is as is. It's probably at the SQL level that this does not work.
>
>The method is called like this:
>
>
>            ' Get the disk space
>            loDriveInformation.cIP = lcIP
>            loDriveInformation.cVolumeName = lcVolumeName
>            If Not loDriveInformation.GetDriveInformationManagementScope() Then
>                ' Do something
>            End If
>
>
>This is the standard code I am using to read the drive information by using a UNC approach. On that drive, it doesn't work.
>
>Does someone know if it is possible to obtain the information from it? Or, is it just that we need to pass a username and a password? From the server, if we access the path as is, it works. But, from the ASP.NET application, it can't.

The share on the SAN will have security, an Access Control List (ACL). You will need to provide a user name and password to get any access to it.

One thing to be wary of is that advanced storage subsystems may use storage quotas. You may find that different users have different quotas, so the "free space" figure could vary depending on the user credentials you supply.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform