So... here's the thing...
I'm connected through sky, which have dynamic IPs and my IP changes once in a while. I'm running a small website from home, the website has, among other things, three video streams from my ip cameras. Now, I don't want to update my code every time the ip changes, so there is this bit at the top of my file:
Response.Buffer = True
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://myip.dnsomatic.com/", False
xml.Send
externalIP = xml.responseText
Set xml = Nothing
My ip changed a while ago, but above code was returning my old IP! When I visited http://myip.dnsomatic.com/, it shown the correct, new IP. The situation persisted as long as I didn't restart my machine. I would like to know why the code behaves like that? Why it doesn't return correct IP right away?
There is one more thing I do not understand... My website has a comments feature, where users can leave a comment. My addComment.asp file checks if the session expired first:
if Session("userID") = "" or Session("username") = "" then
Response.Write("<SCRIPT LANGUAGE=JavaScript>")
Response.Write("alert('Your session has expired...');")
Response.Write("window.location.href='index.html';")
Response.Write("</SCRIPT>")
end if
If the session hasn't expired, the comment is added to the database and the page is updated, but if the session expired, it doesn't go back to index.html, instead, the INSERT INTO statement, which I use to insert the comment into corresponding table, throws an error! That statement is way below above code, theoretically it should never be executed. Any ideas?
I should also add that if the above code is modified following way:
if Session("userID") = "" or Session("username") = "" then
Response.Redirect("index.html")
end if
everything works fine in both cases (session expired and not expired), but I would like a message telling the user about the expiration to pop up. Here's the INSERT INTO statement, which I don't think contains any errors:
conn.Open connStr
commText = "INSERT INTO Messages (ID,
userID,
messageDate,
messageText)
VALUES (" & (recordsQty + 1) & ",
" & currentUserID & ",
#" & Now & "#,
'" & commentText & "')"
conn.Open connStr
conn.Execute commText
conn.Close()
This is just a theory, but I'm guessing that you're getting stale results because it's being cached somewhere. Untested code, but I believe this will solve your problem if it's caching:
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", "http://myip.dnsomatic.com/", False
xml.setRequestHeader "If-None-Match", "some-random-string"
xml.setRequestHeader "Cache-Control", "no-cache,max-age=0"
xml.setRequestHeader "Pragma", "no-cache"
xml.Send
As for continuing to get an error after redirecting, the mistake you're making is not separating server-side from client-side execution of code. Unless aborted, the server-side code will continue to execute to the end. Response.Redirect(String) aborts the execution, although not in a particularly clean way: http://msdn.microsoft.com/en-us/library/t9dwyts4%28v=vs.110%29.aspx
It's much better to modify your code so that it can continue all the way to the end. For example, this may not be pretty depending on how much code you have, but putting the non-redirect path inside of an else block of the if Session("userID") ... block would work.
Edit: I don't have the rep to post comments, but I don't believe this is a DNS caching issue at all, as the myip.dnsomatic.com is simply returning the IP of the client it's serving, which you're then, I assume, directly connecting to. If that's the case, DNS (other than resolving the myip.dnsomatic.com name) isn't involved at all.
Related
We have an old Microsoft Access font end that serves as the GUI to our user database. I was never much of a VBA person so as I go through fixing bugs I'm learning as I go.
Our Access DB has a number of commands to sync info to Active Directory. One such command is to add a user to a group. However, whenever the group contains a / the group is never added.
The debug produces this as:
Run-time error -2147463168 (80005000)': Automation Error".
Printing out the targetgroup shows the DN as I expect it. Trying to escape the / before the GetObject doesn't help and causes its own auth error.
Here's the top part of the function -
Function AddGroup(TargetGroup, strUserID, Optional strOptReqBy)
Dim objDL
Set objUser = GetObject("LDAP://" & GetDName(CStr(strUserID)))
Set objDL = GetObject("LDAP://" & TargetGroup)
On Error Resume Next
objDL.Add (objUser.ADsPath)
objDL.SetInfo
On Error GoTo 0
This works fine if the group does not contain a /.
Debug points to Set objDL = GetObject("LDAP://" & TargetGroup)
Looking for some input on why this is happening. Thanks!
In an LDAP path, the / is a separator. Not only is the // used near the beginning, but you can also specify the server you want to connect to, followed by a /, then the DN of the object, like this:
LDAP://example.com/DC=example,DC=com
That's necessary if the computer you're running this from isn't not joined to the same (or trusted) domain than the domain you're connecting to.
So that means that if the DN of the object you want to bind to has a /, it will think that everything before the / is a server to connect to and it explodes.
So you just need to escape it, which, as you've already learned, is done with a \:
LDAP://OU=This\/That,DC=example,DC=com
So yeah, a simple replace will do:
Set objUser = GetObject("LDAP://" & Replace(GetDName(CStr(strUserID)), "/", "\/")
Don't feel bad. Even Microsoft has this bug in their code.
I have a typical “CDO gmail Email send” macro. It has worked reliably for a couple of years now.
I use a spare gmail account as the address it uses to send from. I want to share the macro with some people. So I will use a different gmail address as the sender.
I have some other spare gmail accounts and also some of the people have registered an account and given me the Username and Password to add to the macro as the sending address.
I have 10 accounts, seven of mine and three registered by others. All work in normal manual use. Three work with the macro, seven don’t.
As far as I can tell. all have identical settings. This includes the unsafe setting of On for “Less secure app access”.
The accounts have been registered at different times over the last two years.
One of the accounts that does not work was registered recently by someone having no previous accounts. One of the accounts that does work has been used almost daily for two years both manually and with the macro.
Two accounts were registered at the same time by two people in my family. They have been used normally/ manually to approximately the same extent for two years, but not previously with my macro. One account works in the macro, the other doesn’t.
These facts suggest to me that the non working accounts have not been blocked for suspected spamming. It seems random which accounts work and which don’t.
Below is a simplified version of the macro. (I can mostly use 465 or 25 as the smtpserverport. The results are almost always identical with either. Only very rarely, one will work whilst the other doesn’t. This seems to depend on the location from which the attempt is made).
The results I get are fairly consistent, including using the macro from different locations and different IP addresses.
I occasionally get security warnings for all accounts when I use the accounts from new locations but I always confirm that “it was me”. After taking this action, I never get security warnings again when using the account at that location. Immediately after such a warning, the account is temporarily blocked but the block is removed after I confirm “it was me”.
Three of the addresses almost always work with the macro. On the rare occasions that they don’t work, a second attempt is usually successful. (Those working addresses have been registered by me sometime in the last two years.)
Seven of the addresses never work with the macro. The error message at the .Send point is always the same:
-2147220975:
Die Nachricht konnte nicht an den SMTP-Server gesendet werden. Der Transportfehlercode lautet 0x80040217. Die Serverantwort lautet not available
An approximate English translation:
-2147220975:
The message could not be sent to the SMTP server. The transport error code is 0x80040217. The server response is not available
(To run the macro below, you must edit to give a real gmailAddress#gmail.com , a real gmailPassword , and real places to send the Email to at the .To and .cc)
Sub Run_gMail_Send_Simplified() ' Run this macro with a valid gmailAddress#gmail.com and gmailPassword and real places to send the Email to at the .To and .cc place
Call gMail_Send_Simplified("gmailAddress#gmail.com ", "gmailPassword")
End Sub
Sub gMail_Send_Simplified(ByVal UsrNme As String, ByVal PsWd As String) '
With CreateObject("CDO.Message") ' ' -------------------* with LCDCW Library ( Linking Configuration Data Cods Wollups) which are used and items configured for the Exchange at Microsoft's protocol therof
Dim LCD_CW As String: Let LCD_CW = "http://schemas.microsoft.com/cdo/configuration/"
.Configuration(LCD_CW & "smtpusessl") = True '
.Configuration(LCD_CW & "smtpauthenticate") = 1
' ' Sever info
.Configuration(LCD_CW & "smtpserver") = "smtp.gmail.com" '
' The mechanism to use to send messages.
.Configuration(LCD_CW & "sendusing") = 2
.Configuration(LCD_CW & "smtpserverport") = 25 ' or 465
.Configuration(LCD_CW & "sendusername") = UsrNme '
.Configuration(LCD_CW & "sendpassword") = PsWd
' Optional - How long to try ( End remote SMTP server configuration section )
.Configuration(LCD_CW & "smtpconnectiontimeout") = 30 '
' Intraction protocol is Set/ Updated
.Configuration.Fields.Update '
'End With ' -------------------* End with LCDCW Library ( Linking Configuration Data Cods Wollups) which are used and items configured for the Exchange at Microsoft's protocol therof
' Data to be sent
.To = "mrlotus123#somemail.com"
.cc = "billandben#someuveremail.com"
.BCC = ""
.from = """gMail_Send_Simplified"" <""" & UsrNme & """>"
.Subject = "Hello from " & UsrNme & " using gMail_Send_Simplified" '
.TextBody = "Hi" & vbNewLine & vbNewLine & "Testing. Please ignore this EMail"
' Do it
On Error GoTo Bed ' Intended to catch a possible predicted error in the next line when running the routine
.send
On Error GoTo 0
Debug.Print "Done " & Format(Now(), "hh mm") & " with Username: " & UsrNme & vbCr & vbLf
End With ' End With CreateObject("CDO.Message") (Rem 1 Library End =======#
Exit Sub
Bed:
Debug.Print "Fail " & Format(Now(), "hh mm") & " with Username: " & UsrNme & vbCr & vbLf & " " & Err.Number & ": " & Err.Description & vbCr & vbLf
End Sub
Any suggestions other than registering accounts and picking out the ones that work?
Is there some setting I may have missed?
Question also posted here:
https://support.google.com/mail/thread/17437986?hl=en&authuser=5
I have the problem solved so I am sharing the solution.
I have now improved the situation from 3 out of 10 accounts working to 11 out of 11 accounts working.
Here are the solution details for anyone else that has a similar problem. I would recommend starting with the solution _4) , as that is the quickest. If that does not solve the problem you will need to look at the others. The others may involve some laborious work.
_1 A strange thing in an old account, which was recently not working in my program and which I had definitely checked many times for Less Secure Apps On.
This account still had in the InBox many old typical Email Warnings from when I had attempted to do things such as logging in different places. ( Often this causes a temporary block, or resetting of Less Secure Apps Off , until you confirm something like “yes, that was me” ). All had been answered by me with “yes it was me”, at least I am 98% sure about that –they all been read, so it is very unlikely that I had ignored them
Never the less , I laboriously re read the Email warnings, and followed the link which almost always confirmed that I had answered, and any given link to the setting showed that it was indeed set to On.
There was one exception : the link showed that the Setting was off. Still looking at any other link or looking in that account settings showed it to be On. But I switched it on anyway, after which the account worked again in my program.
I note that all links in warnings are unique, as they contain information specific to the occurrence which sets off the warning. One explanation of the possible bug is that somehow an answer warning gets set back to unanswered, which blocks the account. The check for validation might be based for some reason on a dynamic process that has all the warnings in a chain, such that all must be answered with yes. This make sense since you can change your answer at a later date. The work around is to re answer all old warnings. In some old accounts I had trashed old Email warnings anymore, so I thought that I could not answer again answer, such that the account would remain blocked, despite showing that it isn’t. But strangely, in the trash folder all old warnings were there despite the default setting of only holding trash for 30 days… https://imgur.com/thNdDaV … very strange, in that screenshot there are entries going back to early 2018, despite the fact that it clearly states there that trash is deleted after 30 days. Other stuff that I trashed is gone.
In future , to be on the safe side, I will archive rather than delete warning Emails, or at least store the link given in it for checking and re setting Less Secure Apps.
_2 Setting suddenly showing (correctly) Off, allowing it to be set to On. Another old account, which was recently not working in my program and which I had definitely checked many times for Less Secure Apps On, suddenly showed Less Secure Apps Off. I then switched it On, and the account worked in my program. This may have been caused indirectly by some of the “cross wire” effects whilst I was looking at effects in other accounts. The moral of this one is not to rely on checking the setting just once, as later it might change for no apparent reason.
_ 3) I mentioned in the original post that my personal telephone cant be used any more to verify a new account, (gmail only allow a few uses for SMS confirmation – they deliberately do not say how many). Mostly that is still the case. On one random attempt during my experiments it worked. The new account then also worked in my program. – Hence I have 11 out of 11 now working, rather than 10 out of 10.
Similar conclusion again here: Don’t rely on the situation being static, some external thing may have some effect giving you a short period to do something that is generally not possible.
_4) Links going to wrong accounts. This mostly happens when I have other accounts open, but occasionally it also happens when I only have one account open.
As example: I get a valid warning based on some activity that I do on an account: https://imgur.com/VTAJOWc , I give it the OK, https://imgur.com/mKskkzx , and I then see a notice informing me that the Less Secure Apps has been set to Off, https://imgur.com/9bNePXf . So I follow the link for further info: https://imgur.com/LpGQYlj , and there after I follow a link to turn Less Secure Apps back on, https://imgur.com/WuMjPml . So far so good – note the account shown in the coloured ball top right is the correct one: https://imgur.com/yj09MsX
Now it gets interesting: I end up at the wrong account: https://imgur.com/T050wP4
That is easy to overlook. The solution here was to ignore links given and go directly to settings on the correct account, preferably soon after you get the warning. If you do not do that, then not only will you possibly not get to set the correct account, but also you possibly get another undesirable effect: sometimes the act of following the ( “crossed” ) link seemed to set off sporadic warnings and setting changes on other accounts !!!
This is all suggesting to me that there is some “cross wire type” bugs somewhere in Google.
_ 5 ) Rogue account getting other accounts warnings. This is related to _4) , but in particular one of my accounts not only got effected by following the “cross wired links” , but also frequently gets the warnings that should go to the other accounts. This happens even when I am not using that account anywhere. Once again this suggests some “cross wiring / leakage” caused by Google tracking what I , personally , am doing
_.______________
The short answer to what the problem was/is, is possibly that Less Safe App access was being blocked/ temporarily tuned Off, but for varied reasons it was not easy to switch it back On, since the obvious way to do that via settings was no use since it was often indicated as already On, and in some cases , just looking at it caused other account settings to change!!
I am slightly put off using gmail in my program. I have some concern that Google in its “spying” has got “cross wires / leakage” and it has grown into an uncontrollable monster that will probably break out of its server and appear in front of me and try kill me …… I actually registered the particular account discussed in _5) when I was away from home in India!!! ………… “…You are experiencing a car accident … The hell I am..” -- https://www.youtube.com/watch?v=L0Fw8TVYBKg
_.__________________-
I think we have all experienced at one time or another that adverts seem to pop up which obviously have got some “inside information” about us, which amongst other sources, may come from some Google “spying” on you . I use the word “spying” loosely – most likely we have agreed to it when agreeing to something without fully reading all the small print.
My recent experience is showing that I can follow links to change settings on one of my Google accounts, and then actually change settings on other accounts, even if I am not logged into these accounts. Further, I can change setting in one of my accounts, and it will cause changes in other accounts. I am not sure if that is supposed to happen. But it certainly does happen to me on some of my computers.
The common thing that is causing this cross wiring may be Google chrome browser. I should say finally that I am using a very old version often , in Vista. Possibly these issues do not arise if you only use a newer version..
Alan
I'm a novice and your help has been amazing so far! I have an issue with a GET request for SSO authentication in an Excel Visual Basic script. The API says to send the GET request to:
https://services.example.com/API/Security.svc/SSOSiteLogin/siteId/enterpriseGuid/authToken/timezoneOffset
Where the values for siteID, enterpriseGUID, authToken, and timezoneOffset have all been obtained by previous GET requests, which have worked fine. When I send the final GET request for a security token, it returns:
{"Detail":"SSOSiteLogin failed.Input string was not in a correct format."}
Here is my relevant code:
Dim hreq As New WinHttpRequest
Dim response As String
Dim URL As String
'get security token
URL = "https://services.example.com/API/Security.svc/SSOSiteLogin/siteID/enterpriseGUID/" & authToken & "/null"
hreq.Open "GET", URL, False
hreq.Send
response = hreq.ResponseText
Range("A13") = response
The siteID and enterpriseGUID variables are input into the code, and the authToken is stored from an earlier POST request. The last value, timezoneOffset, is given as "null" from an earlier request so I've been typing "/null" at the end but I'm concerned that's what's triggering the incorrect format response. Anything else just returns a total error from the server though.
Any ideas? Thank you in advance!
I had put the values into cells and was sending the GET request as "Range("E5") & "/" & Range("E6") & "/", etc. so that I could try a couple of debugging issues without having to go to the VBA editor and for some reason that worked! I ended up using the string "null", too. If anyone knows why this worked and inputting it all as one string doesn't I'd be interested to find out.
I've played with ASP classic and VB Script a few years since that's what we have at our company, but this is really bothering me. We bought the CJWSoft ASP Protect, and did some customizing, if anyone is familiar with it. Every page I log into ends with a question mark at the end of the URL and displays an internal server 500 error (using a testing server: Windows Web Server 2008 R2). One would think it would always go to the default.asp page upon login, but that doesn't happen unless I open a new window, which it's set to not store cookies. I can access any page I log into after I clear the question mark at the end of the URL. I have IT guys here, but we're not sure what's causing it.
(IP Address/Default.asp? [or] IP Address/password_admin/default.asp?) produces an
Internal Server Error 500.
Remove the ? and I'm into any of the pages on the server. Why?
I think the following script may have something to do with it, or whatever relates to it...
If Session("PasswordAccess") = "No" Then
Thispage = Request.ServerVariables("script_name")
Else
'Thispage = Request.ServerVariables("script_name") & "?" & Request.Querystring & Request.Form
'Setting Below is more secure than the setting above which allows form post data to be re-returned to the page
Thispage = Request.ServerVariables("script_name") & "?" & Request.Querystring
End If
Please help me resolve the question mark, anything else is a grand bonus!
What about only appending that ? if the query string isn't empty?
Like
<%
Thispage = Request.ServerVariables("script_name")
Dim qst : qst = Request.ServerVariables("QUERY_STRING")
if qst<>"" then Thispage = Thispage & "?" & qst
%>
I'm getting a persistent error:
The element cannot be found in a collection.
This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
I've checked, double and triple-checked my variable listings in the Read-Only and Read-Write variables in my Script task.
I've debugged it to death and gotten input from another programmer here who couldn't spot the issue either.
I've also researched to no end.
Does anyone see anything wrong with my code?
Script Task code:
Public Sub Main()
Dts.Variables("User::strMailBody").Value = "Thank you for submission. For your convenience, we are including the last four of the HICN# and the Name on the application(s) we have received* from you." _
& vbNewLine & vbNewLine & "Here are the following: " & vbNewLine & vbNewLine
Dts.Variables("User::strMailBody").Value = Dts.Variables("User::strMailbody").Value.ToString() & vbNewLine & Dts.Variables("User::strListing").Value.ToString()
Dts.Variables("User::strMailBody").Value = Dts.Variables("User::strMailBody").Value.ToString() & vbNewLine & vbNewLine & Dts.Variables("User::strFooter").Value.ToString()
If Left(Dts.Variables("User::strAgentID").Value, 2) = "TX" Then
Dts.Variables("User::strSubject").Value = "ACME Health Plans Confirmation: Total "
Else
Dts.Variables("User::strSubject").Value = "ACME2 Baptist Health Plans Confirmation: Total "
End If
Dts.Variables("User::strSubject").Value = Dts.Variables("User::strSubject").Value.ToString() & Dts.Variables("User::lngCountAgent").Value.ToString() & " " & "[RESTRICTED: CONFIDENTIAL]"
Dts.Variables("User::DateSent").Value = Now()
Dts.Variables("User::UserSent").Value = "SSIS"
Dts.TaskResult = ScriptResults.Success
End Sub
For anybody else struggling with this issue the resolution for me was as follows: (note I am NOT using User:: when getting variable values within my script task)
On the package Properties I hadn't included the variables as ReadOnlyVariables
You'll need to set your newly added variables as follows:
Right click on the package and select Edit
In the Script section click on ReadOnlyVariables or ReadWriteVariables (depending on your how you want your variables behave)
Check the check-box beside the variables you wish to use in your script task
Click Ok to save your changes
Hope this helps
I just had the same issue and unable to find the problem for ages. I found that the reason for the error was that I had missed one of the colons between "User" and the variable name.
I had this (which caused the error):
string FileName = UserVariables["User:CurrentFileName"].Value.ToString();
when I should have had this:
string FileName = UserVariables["User::CurrentFileName"].Value.ToString();
just in case anyone else has the same problem :)
Ohhh.........man. It's amazing how you can stare at this stuff and miss something stupid, for hours.
strFooter was missing in the listing.
ALL SET NOW. Sincere thanks to those who looked and commented. Eric, thanks, I'll remember that as sometimes I will probably need to use C insatead of VB (haven't yet but will).
Had a similar issue, after a lot of debugging, realized that the variable naming convention should be User::varname and NOT USER::varname
I guess c# is very case sensitive.
Hope this helps and saves you lot of your valuable time :-)
a) Right click on the script task and choose edit
b) Locate the Read or Read/Write variables properties in the list.
c) Click on the property and the variable you wish to access in the script task.
Another variation on "have been staring at the screen for too long to see the typo". In my case, I got the same error by mixing up the syntax between Project Params and User variables, and adding a $ sign in front of User.
error :
string varA = (string)Dts.Variables["$Project::ParamA"].Value
string varB = (string)Dts.Variables["$User::ParamB"].Value
corrected :
string varA = (string)Dts.Variables["$Project::ParamA"].Value
string varB = (string)Dts.Variables["User::ParamB"].Value