Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing SAN drive
Message
From
30/05/2012 01:51:32
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
Accessing SAN drive
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:
01544730
Views:
55
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.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform