Classic ASP and ixsso.query returns EOF - asp-classic

I have come across a bit weird problem with classic asp site which uses indexing service to search folder by given parameter and then lists files from the folder. Folder names are unique so the query should return only one recordset. Site is running at w2k8 64 environment. Before it was running in w2k3 server.
Basically everything runs okay but at some rare cases with specific folders query doesn't return anything at all. And this happens only if I go to the site from remote location. If I go to the site at localhost everything works just fine with those problematic cases.
Here is the code block
Dim strQuery
strQuery = "#all " & target & "*"
Set ixQuery = Server.CreateObject("ixsso.Query")
ixQuery.Query = strQuery
ixQuery.Catalog = "Reports" '
ixQuery.SortBy = "create [d], filename [a]"
ixQuery.Columns = "DocTitle, path, filename, size, create, directory"
ixQuery.MaxRecords = 150000
Dim util
Set util = Server.CreateObject("ixsso.Util")
util.AddScopeToQuery ixQuery, Server.MapPath("Reports"), "deep"
Sim queryRS ' Query recordset.
Set queryRS = ixQuery.CreateRecordSet("nonsequential")
Has anyone came up with same kind of problem? Any ideas how to solve it?
Update: I rewroted the program in ASP.NET because it wouldn't work as classic asp.

Related

Open file in another server using ip address using asp.net

I have a shared folder containing a list of wav files i wish to open this files from my asp.net application.
everything is working good when we launch our application from loaclhost but after deploying it it is not workin ( it can not find files)
my code :
Dim oDirectories As String() = Directory.GetFiles("\\192.168.1.160\records\Files\" & dateC & "\", "*.wav")
Dim files As List(Of String) = (From q In oDirectories
Where q.Contains(indice)
Select q).ToList()
Dim liststrings As Integer = files.Count
ListBox1.DataSource = files
ListBox1.DataBind()
When you saying "deploying" - what do you actually mean - to a public/hosting server? Realize that you are using a private IP - which in, and of itself, doesn't always point to the problem (it's possible, depending on your type of hosting account - re: dedicated subnet), but based on the info you provided, that would be where to look first.

how to get cordova filetransfer parameters

am using an asp.net website to receive files from a mobile device using Cordova 3.2.0 FileTransfer.upload command.
This can take parameters which are added to the options(see doco)....so how do I get the parameters?
Tried using:
Dim params As NameValueCollection = HttpContext.Current.Request.Params
UtilityManager.Log_Add("params count: " & params.Count)
For Each key As String In params.AllKeys
stmp = params.GetValues(key)
For x As Integer = 0 To stmp.Length - 1
UtilityManager.Log_Add("Key:" & key & " has value: " & stmp(x) & " at position: " & x)
Next
Next
but get none of my parameters, just the usual request parameters.
Tried the same thing on the Headers but the hosting site is using IIS6 and not in pieline mode so getting an error.
Originally tried WCF but for some reason it didn't like multi-part forms so I kept getting a File Not Found error in phonegap and it wouldn't even enter the function on the server. Could access the server function using Chrome Poster so don't know what is happening there.
Tested it on a aspx page and that worked so added an asmx service to do the work and it seems to be working fine with regards the file and options (except for the arguments). Maybe I should just put them through as querystrings (bad practice).
Trawled the web for a day to get the answer but it doesn't seem to be any out there....any suggestions?

ASP.NET & IIS 7.0 -- HTTPS Site Warmup Script

I have an ASP.NET 4.0 site on IIS 7.0 that is having first time load issues described here.
I've done some testing, and can confirm that it's only the first load of the page that is slow; every subsequent page loads normally. After googling around for this, I found a "warmup" script that can send an HTTP request the first time after the app pool is recycled, and this seems to fix the problem. BUT, I'm not sure if it will work when I force set the page to use only HTTPS/SSL?
The script I'm currently using is as follows:
Dim website1
website1 = "http://<website domain>/Auth/Login.aspx"
Function WarmUpSite(strURL)
On Error Resume Next
Dim objHTTP
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
objHTTP.Open "GET", strURL, False
objHTTP.Send
If Err.Number=0 And objHTTP.Status=200 Then
Hget=strURL & " has been warmed up successfully at: "&Date()&" "&Time()
Else
Hget=strURL & " found error at: "&Date()&" "&Time()
End If
Set objHTTP = Nothing
'Section for writing into a text file
Const FOR_APPENDING = 8
strFileName = "C:\WarmUpLog.txt"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFileName,FOR_APPENDING)
objTS.WriteLine Hget
End Function
WarmUpSite(website1)
So my question is how I would make this work if the website I'm warming up is a login page that will be an HTTPS address, not HTTP? My apologies if this is a dumb question, I do relatively little web work.
Well, apparently it just involved changing the value of website1 to an HTTPS url.
;)

Changing file permissions results in IdentityNotMappedException (when code is ran on web server)

I have the following code (from msdn) to set file permissions:
' Adds an ACL entry on the specified file for the specified account.
Sub AddFileSecurity(ByVal fileName As String, ByVal account As String, ByVal rights As FileSystemRights, ByVal controlType As AccessControlType)
' Get a FileSecurity object that represents the
' current security settings.
Dim fSecurity As FileSecurity = File.GetAccessControl(fileName)
' Add the FileSystemAccessRule to the security settings.
Dim accessRule As FileSystemAccessRule = New FileSystemAccessRule(account, rights, controlType)
fSecurity.AddAccessRule(accessRule)
' Set the new access settings.
File.SetAccessControl(fileName, fSecurity)
End Sub
I call this using the group IIS_IUSRS (I've tried ComputerName/IIS_IUSRS too) and I'm trying to apply FileSystemRights.FullControl
But results in this error:
System.Security.Principal.IdentityNotMappedException: Some or all identity references could not be translated
Which suggests IIS_IUSRS doesn't exist (it does). My next step is to output the users and groups on the machine to see what my code thinks does exist. In the mean time does anyone know why, or what is causing this?
This code works fine on my local machine but not when run on my web server. The app pool runs as network service and Network Server has FULL permission on the folder the files are in. I noticed this question that suggests the user needs permission on the directory - but this isn't the problem.
To work around this, change the authentication on the website to run as "Same as app pool" (as opposed to anonymous). Not the best answer, but have tried everything else.

401 Unauthorised errors when attempting to download ASP page to file

Issue
Msxml2.ServerXMLHTTP keeps returning 401 - Unauthorised errors each time we attempt to read the contents of a file (ASP) from a web server.
Source server is running IIS6, using NTLM integrated login.
This process has been used successfully before, but only in as far as extracting XML files from external websites, not internal ones.
The proxy settings in the registry of the server on which the script is run has also been updated to bypass the website in question, but to no avail.
All paths identified in the VBScript have been checked and tested, and are correct.
User running the script has correct read/write permissions for all locations referenced in the script.
Solution needed
To identify the cause of the HTTP 401 Unauthorised messages, so that the script will work as intended.
Description
Our organisation operates an intranet, where the content is replicated to servers at each of our remote sites. This ensures these sites have continued fast access to important information, documentation and data, even in the event of losing connectivity.
We are in the middle of improving the listing and management of Forms (those pesky pieces of paper that have to be filled in for specific tasks). This involves establising a database of all our forms.
However, as the organisation hasn't been smart enough to invest in MSSQL Server instances at each site, replication of the database and accessing it from the local SQL server isn't an option.
To work around this, I have constructed a series of views (ASP pages) which display the required data. I then intend to use Msxml2.ServerXMLHTTP by VBScript, so I can read the resulting pages and save the output to a static file back on the server.
From there, the existing replication process can stream these files out to the site - with users having no idea that they're looking at a static page that just happened to be generated from database output.
Code
' Forms - Static Page Generator
' Implimented 2011-02-15 by Michael Harris
' Purpose: To download the contents of a page, and save that page to a static file.
' Target category: 1 (Contracts)
' Target Page:
' http://sharename.fpc.wa.gov.au/corporate/forms/generator/index.asp
' Target path: \\servername\sharename\corporate\forms\index.asp
' Resulting URL: http://sharename.fpc.wa.gov.au/corporate/forms/index.asp
' Remove read only
' Remove read only flag on file if present to allow editing
' If file has been set to read only by automated process, turn off read only
Const READ_ONLY = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("\\server\sharename\corporate\forms\index.asp")
If objFile.Attributes AND READ_ONLY Then
objFile.Attributes = objFile.Attributes XOR READ_ONLY
End If
Dim webObj, strURL
Set webObj = CreateObject("Msxml2.ServerXMLHTTP")
strURL = "http://sharename.fpc.wa.gov.au/corporate/forms/generator/index.asp"
webObj.Open "GET", strURL
webObj.send
If webObj.Status=200 Then
Set objFso = CreateObject("Scripting.FileSystemObject")
Set txtFile = objFso.OpenTextFile("file:\\servername.fpc.wa.gov.au\sharename\corporate\forms\index.asp", 2, True)
txtFile.WriteLine webObj.responseText
txtFile.close
ElseIf webObj.Status >= 400 And webObj.Status <= 599 Then
MsgBox "Error Occurred : " & webObj.Status & " - " & webObj.statusText
Else
MsgBox webObj.ResponseText
End If
Replace your line:
webObj.Open "GET", strURL
With:
webObj.Open "GET", strURL, False, "username", "password"
In most cases 401 Unauthorized means you haven't supplied credentials. Also you should specifiy False to indicate you don't want async mode.
It sounds like the O.P. got this working with the correct proxy settings in the registry (http://support.microsoft.com/kb/291008 explains why proxy configuration will fix this). Newer versions of ServerXMLHTTP have a setProxy method that can be used to set the necessary proxy configuration in your code instead.
In the O.P. code above, after webObj is created, the following line of code would set up the proxy correctly:
webObj.setProxy 2, "0.0.0.0:80", "*.fpc.wa.gov.au"
ServerXMLHTTP will pass on the credentials of the user running the code if it is configured with a proxy, and if the target URL bypasses that proxy. Since you are bypassing the proxy anyway, you can make it a dummy value "0.0.0.0:80", and make sure your target url is covered by what you specify in the bypass list "*.fpc.wa.gov.au"
I would first test if you can reach your url through a normal browser on the same server X you run your code on (A). I would try then reach the url from another PC. One never used to reach that url but in the same network as server X (B).
If B works but A doesn't I would suspect that for some reason your source server (i.e. that one that serves the url) blocks server X for some reason. Check the security settings of II6 and of NTLM.
If both A and B don't work, there is something wrong more in general with your source server (i.e. it blocks everything or NTML doesn't allow you in).
If A works (B doesn't matter then), the problem has to be somewhere in your code. In that case, I would recommend fiddler. This tool can give you the HTTP requests of both your browser and your code in realtime. You can then compare both. That should give you at least a very strong hint about (if not immediately give you) the solution.

Resources