Retrieving a image file from a website by passing credentials - vb6

Using Visual Basic 6.0. My code needs to pull picture images from a website and download to c:\temp location.
To access the website we need to pass credentials; upon successful login the images automatically downloads. Sample code:
'retrieve image from URL
getURL = "http://mrldata#abc.com:8080/mrldata/compounds/" & lnumber & ".jpg?"
Randomize
localFile = "C:\temp\" & Hour(Now()) & Minute(Now()) & Second(Now()) & Int(Rnd * 10) & ".jpg"
CopyURLToFile getURL, localFile
How can credentials be passed in order to access the website?

Related

How to connect to Database app path - vb6

Im trying to connect my databases(not binded/flexible) and it will run when the form activated. But in my code it kept error and didn't connected to the database. This is my last code:
Private Sub LoginForm_Activate()
Aadodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database\Login.mdb;Persist Security Info=False"
Aadodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database\login.mdb;Persist Security Info=False"
End Sub
I have ever connected it through the adodc property. But after i run it it broke if i move the folder to another folder so i tried to connect it using a flexible connectionstring.
I have found it out, the adodc should be refreshed Aadodc1.Refresh and the record source Aadodc1.RecordSource = "Select * from [table name]" must be defined. That's all :)

How to retrieve URL dynamically?

I am using a webservice in my project. I am giving URL like this:
WebServicename.asmx/Methodname
Locally I used webservice in VBScript and it is running good. But when I deployed same code in a server the webservice is not running. So before that webservice I want to give full URL. So for that reason I want to get that URL dynamically and add before of my URL.
I am writing Vb script and I call webservice like this
Set oXMLHTTP = CreateObject("MSXML2.XMLHTTP.3.0")
Set oXMLDoc = CreateObject("MSXML2.DOMDocument")
'Msgbox("Calling WebService To Approve Leave")
strEnvelope ="varCarrierType="&varCarrierType &varCarrierID& "&Filename="&Filename& "&varC22Cnt="&varC22Cnt&"&varCurrentDateTime="&varCurrentDateTime&"&varTotalCommissionAmt="&varTotalCommissionAmt&"&vpath="&vpath
oXMLHTTP.onreadystatechange = getRef("HandleStateChange")
call oXMLHTTP.open("POST","/VBScriptService.asmx/InsertDBDetails",False)
call oXMLHTTP.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
call oXMLHTTP.send(strEnvelope)
MsgBox "COM File successfully generated from the Template given. Verify the output file in " & vpath,0, "Com File Generation"
MsgBox "Page About to Refresh, Click ok to proceed", 0, "ComPage Refresh"
Set wShell=CreateObject("WScript.Shell")
wShell.SendKeys "{F5}"

What default credential Directory Entry binds to if it is running as a service on Windows

If I bind to a DirectoryEntry ( without any arguments) on the application mode to search all the users at my current domain, I could see the logged in in user is the default credential for DirectoryEntry since it finds all the users for my domain. With that, I would expect that this won't work if the application is run at service mode since account for service is SYSTEM which is not a user of my domain. However the code still works and it could get all the users of my logged in user domain.
I did some search on internet, I didn't find any answer on this when running as a service. Any idea? Any way I could get that default credential at power shell?
At service mode, the default credential for directory entry would be the credential which computer is used to login into the domain (called computer login). See this link: https://serverfault.com/questions/61191/what-happens-when-a-computer-joins-an-active-directory-domain.
I first tried to use System.Net.CredentialCache::DefaultNetworkCredentials
to try to get the default credential, however I found out the user and domain are all blank. It is confirmed from MSDN that we could not view those info with the returned NetworkCredentials.
So I added the following vb script (got the base code from this link: http://blogs.technet.com/b/heyscriptingguy/archive/2008/05/12/how-can-i-determine-the-distinguished-name-of-the-ou-where-the-logged-on-user-s-user-account-resides.aspx) to be called from power shell to get the dn of the current user
and save it to a file.
Set objSysInfo = CreateObject("ADSystemInfo")
strUserName = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUserName)
Wscript.Echo objUser.distinguishedName
Set objFS = CreateObject("Scripting.FileSystemObject")
strTemp = "c:\temp\dn.txt"
Set objOutFile = objFS.CreateTextFile(strTemp,True)
objOutFile.Write(objUser.distinguishedName)
objOutFile.Close
Then when I ran it in service context, I found out that user is my computer itself, like this:
CN=my computer name,OU=Domain computer accounts,DC=domain,DC=local

Whats the best way to Programmatically Process New Email Messages and Store Attachments

I have several clients/vendors that distribute reports to me via email. Some of these files are enormous, and need to be removed from email and saved on a file share for processing, as well as to control mailbox size.
Can anyone provide guidance on their recommended method of automatically downloading and saving attachments.
I am in a MS Windows Environment (Client & Server Computers). Emails are on an Microsoft Exchange 2003 Email Server.
Preferred use of Microsoft Technology for consistency across solutions (C#), however I am open to any suggestions, be it C#, VBScript, Perl, Java, Components I should purchase, etc..
Scenario
Each Day bob#whysendmereportsbyemail.com sends an email with the subject "Activity Report for YYYY-MM-DD" to me at
john#myemailaddress.com
Each Email has an attachment named "ActivityReport-YYYY-MM-DD-HH-MI-SS.xls" which I need to save on my filesystem at
"C:\FilesFromBob\ActivityReport-YYYY-MM-DD-HH-MI-SS.xls"
Thanks in advance for any assistance.
Exchange 2003 provides a WebDav API which you can use to access emails, contacts etc.. from a user's account.
There's a few answers about accessing a user's Exchange inbox on SO already. I've previously used this approach for almost exactly the situation you outline, and once you work out the WebDav API model and the structure of the requests and responses, it's not too difficult to extract emails and their attachments.
There are other ways to interact with Exchange 2003 (outlined on SO here), but I've only tried the WebDav approach because it seemed the most reliable.
I finally wrote the code to store messages from Outlook
Unfortunately this code runs from within Outlook, so Outlook has to be open.
I did not yet investigate how to schedule the run, but now its easy to do
Sub SaveOutlookFileAttachments()
Dim oStores As Outlook.Stores
Dim oStore As Outlook.Store
Dim oFolders As Outlook.Folders
Dim oFolder As Outlook.Folder
Dim destFolder As String
Dim oItems As Outlook.Items
Dim oMsg As Outlook.MailItem
Dim oAttachments As Outlook.Attachments
Dim oAttachment As Outlook.Attachment
Dim oExplorer As Outlook.Explorer
destFolder = "\\NetworkShare\OrderDetailReport\"
On Error Resume Next
Set oStores = Application.Session.Stores
For Each oStore In oStores
If oStore.DisplayName = "Inbox" Then
oFolders = oStore.GetSearchFolders
For Each oFolder In oFolders
oItems = oFolder.Items
For Each oMsg In oItems
oAttachments = oMsg.Attachments
For Each oAttachment In oAttachments
If InStr(1, oAttachment.FileName, "orderdetail_", vbTextCompare) Then
'MsgBox ("This File Needs to be Saved: " & oAttachment.FileName)
oAttachment.SaveAsFile (destFolder & oAtch.DisplayName)
End If
Next
Next
Next
End If
Next
End Sub

Is there a way to check the MS Security Center for virus protection status?

We are in a Windows environment and looking to automate this process for non-company machines. If a vendor comes on site, we'd like to be able to have him/her hit a website that can perform a quick scan of the workstation to determine if they have the proper MS KB patches and if their virus scanner dats are up to date.
I can scan for the KB updates relatively easy, what I'm having a hard time finding is a way to check the virus dat status and since there are so many different engines out there, it seemed to make sense to use the (built into XP at least) proprietary MS security center stuff.
Eventually we'd like to have our routers redirect non-company machines to a website that will force validation, but until that point it will be a manual process.
Any thoughts?
In Windows Vista there are some new APIs to interface with the Security Center component status: http://msdn2.microsoft.com/en-us/library/bb963845(VS.85).aspx
Through WMI, here's a VBS code snippet I checked out on http://social.msdn.microsoft.com/forums/en-US/windowssecurity/thread/bd97d9e6-75c1-4f58-9573-9009df5de19b/ to dump Antivirus product information:
Set oWMI = GetObject
("winmgmts:{impersonationLevel=impersonate}!\\.\root\SecurityCenter")
Set colItems = oWMI.ExecQuery("Select * from AntiVirusProduct")
For Each objAntiVirusProduct In colItems
msg = msg & "companyName: " & objAntiVirusProduct.companyName & vbCrLf
msg = msg & "displayName: " & objAntiVirusProduct.displayName & vbCrLf
msg = msg & "instanceGuid: " & objAntiVirusProduct.instanceGuid & vbCrLf
msg = msg & "onAccessScanningEnabled: "
& objAntiVirusProduct.onAccessScanningEnabled & vbCrLf
msg = msg & "productUptoDate: " & objAntiVirusProduct.productUptoDate & vbCrLf
msg = msg & "versionNumber: " & objAntiVirusProduct.versionNumber & vbCrLf
msg = msg & vbCrLf
Next
WScript.Echo msg
For AVs that don’t report to WMI or for AVs which WMI retains state info after the AV is uninstalled (there are instances of both cases) you may wish to consider the OPSWAT library.
You will need to write and deploy a light client from your website to utilize the library to machines to be interrogated.
The library utilizes WMI for security apps that correctly support WMI and proprietary methods to detect AVs and their dat status for those that don’t.

Resources