Showing posts with label ActiveX. Show all posts
Showing posts with label ActiveX. Show all posts

Monday, July 09, 2007

Merlin the great!

Imagine how amazed your users will be when they login to the domain and Merlin greets them...

You can call Merlin using Agent Control and make do the moves while you perform you login scripts in the background...

You can load information about the logged on user either using ADSI scripts or just by reading on the environment variable table...

Take note of the length of the messages or actions you throw at Merlin, you might need to make use of the Sleep method, otherwise the sentences or the animation will overlap...

Code Snippet:


  1. strAgentName = "Merlin"
  2. strAgentPath = "Msagent\Chars\" & strAgentName & ".acs"
  3. Set objAgent = CreateObject("Agent.Control.2")
  4. objAgent.Connected = True
  5. objAgent.Characters.Load strAgentName, strAgentPath
  6. Set merlin_d_great = objAgent.Characters.Character(strAgentName)
  7. With merlin_d_great
  8. .Show
  9. Set objRequest = .MoveTo(500,400)
  10. Set objRequest = .Play("Announce")
  11. Set objRequest = .Play("Explain")
  12. Set objRequest = .Speak("Hi ")
  13. Set objRequest = .Play("Read")
  14. wscript.sleep 2000
  15. Set objRequest = .Speak("Today is " & Now() & "...")
  16. Set objRequest = .Play("ReadContinued")
  17. wscript.sleep 2000
  18. Set objRequest = .Speak("and the time is " & Time() & "...")
  19. wscript.sleep 2000
  20. Set objRequest = .Play("ReadReturn")
  21. wscript.sleep 2000
  22. Set objRequest = .MoveTo(750, 450)
  23. Set objRequest = .Play("Pleased")
  24. wscript.sleep 5000
  25. Set objRequest = .Speak("I will be back shortly...")
  26. wscript.sleep 5000
  27. Set objRequest = .Play("Wave")
  28. wscript.sleep 5000
  29. .Hide
  30. End With

Have a blast with Merlin, and oh... you can use other characters aswell...

If at first you fail, call it version 1.0

Tuesday, June 26, 2007

Kix FTP (Kixtart UDF)

FTP via Kix? Yes!!!

Using Microsoft.XMLHTTP and ADODB.Stream.

Usage:

FTPget("ftp_address", "target_dest_drive", "id", "password")

Code Snippet:

  1. Function FTPget($sURL, $sTargetFile, optional $sUser, optional $sPass)
  2. Dim $oFTP, $oStream $sUser=""+$sUser
  3. $oFTP = CreateObject("Microsoft.XMLHTTP")
  4. if @error
  5. $ftpget=1
  6. exit 1
  7. endif
  8. $oStream = CreateObject("ADODB.Stream")
  9. if @error
  10. $ftpget=2
  11. exit 2
  12. endif
  13. if $sUser
  14. $oFTP.Open("GET", $sURL, not 1, $sUser, $sPass)
  15. else
  16. $oFTP.Open("GET", $sURL, not 1)
  17. endif
  18. if @error
  19. $ftpget=3
  20. exit 3
  21. endif
  22. $oFTP.Send
  23. $oStream.Type = 1
  24. $oStream.Mode = 3
  25. $oStream.open
  26. $oStream.Write($oFTP.responseBody)
  27. if @error
  28. $ftpget=4
  29. exit 4
  30. endif
  31. $oStream.SaveToFile($sTargetFile, 2)
  32. if @error
  33. $ftpget=5
  34. exit 5
  35. endif
  36. $oStream.Close
  37. EndFunction


If at first you fail, call it version 1.0

Saturday, June 16, 2007

PHP HTTP_X_FORWARDED_FOR versus WPAD

I was working on one of our company's website running on Apache with PHP and MySQL.

I seems that when users are accessing the site thru our company's proxy server, the updates fail to reflect on the MySQL database (IE really sucks!).

So I decided to write a 2 part php function that captures the client's IP Adress and Referrer if the traffic originated from a proxy server and compares it against known Proxy server IP's and Hostname and disallow the clients from accessing the site and prompts a message to remind the user to disable the IE's proxy server settings when accessing to the site.


Code Snippet:

  1. function GetIP()
  2. {
  3. if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
  4. $ip = getenv("HTTP_CLIENT_IP");
  5. else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
  6. $ip = getenv("HTTP_X_FORWARDED_FOR");
  7. else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
  8. $ip = getenv("REMOTE_ADDR");
  9. else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
  10. $ip = $_SERVER['REMOTE_ADDR'];
  11. else
  12. $ip = "unknown";
  13. return($ip);
  14. }
  15. $badreferer=$CompanyProxyServer;
  16. $referer=GetIP();
  17. if ($referer==$badreferer)
  18. {
  19. echo "<br>";
  20. echo "<center><h4>Disable your proxy server settings and clear your IE cache, then return to this page.</h4></center>";
  21. exit;
  22. }


Well, you know... users will be users...

Although the site prompts a reminder to remove the proxy settings when accessing the pages, most of them still find it difficult to click Tools -> Internet Options -> Conenctions Tab -> LAN Settings and un-tick the use proxy server options.

So to put a permanent fix, I relied on WPAD and permanently excluded the site from utilizing the proxy server when accessing the site via the MatchDirect function:

if (MatchDIRECT(host))
{
return "DIRECT";
}

I also added an extra entry to treat the site as Local Intranet Site, since the security settings only allows ActiveX to be installed and executed from Trusted Sites and Local Intranet Sites.

This also helps in another problem that our company's domain is the same as our public internet domain name.

function FindProxy(host, intranet, internet)
{
if (MatchInternet(host))
{
return internet;
}
else if (dnsDomainIs(host, ".ourcompanyname.com")|
(isPlainHostName(host))|
(MatchIntranetIpRange(host))|
(dnsDomainIs(host, ".ourcompanyname.net")))
{
return intranet;
}
else
{
return internet;
}
}


Now all I needed was a GPO that pushes the Automatic Configuration script (http://OurWebServer/WPAD.dat) to the machines.

House the WPAD script on a central Web Server and Voila!

If at first you fail, call it version 1.0