Break into Debugger when Exception is thrown even if you are using try catch statements.
From Visual Studio, hit CTRL + ALT + E. Then check the “Thrown attribute of the Common Language Runtime Exceptions.
Post Comment Now

Break into Debugger when Exception is thrown even if you are using try catch statements.
From Visual Studio, hit CTRL + ALT + E. Then check the “Thrown attribute of the Common Language Runtime Exceptions.
I was bored today so I created a very simple and fast php script to plot the location for a given IP and display other IP information (such as lattitude, longitude, Country, State, Area code, ISP, etc.) on a Google Map using the Maxmind web service and the Google Maps API.
The link in the balloon points domaintools.com and does a whois lookup on the IP for detailed information on the ISP (internet service provider).
Here is a working demo (hard coded IP).
In order for this script to work on your site, you will need a MaxMind GeoIP City/ISP/Organization Web Service Key (50,000 lookups for $20.00) and a Google Maps Key (free). There are other IP to Lat/Long Web services out there but Maxmind is by far the most accurate (none are 100% accurate).
To render the location of an IP on the map, send the IP via the query string such as…
http://www.yourDomain.com/MaxmindGoogleMap/index.php?ip=98.195.83.50
Here is the script. Copy the contents to a .php file and edit the 2 keys. That’s it!
<?php ////////////////////////////////////////////////////////////////////////////////////// /////////////// Maxmind/Google Maps Mashup by Kevin Cornwell /////////////// /////////////// Version 1.0 /////////////// /////////////// http://www.kevincornwell.com /////////////// ///////////////////////////////////////////////////////////////////////////////////// // EDIT THE NEXT 2 KEYS $maxmind_license_key = "foo"; // Replace [foo] with your key. $google_maps_key = "bar"; // Replace [bar] with your key. $zoom = 4; // Default zoom level. $lat = 39.232; // Center on this location by default when no IP is passed. $long = -95.800; // Center on this location by default when no IP is passed. $ip = ""; $message = "Hello World"; // Default message when no IP is passed. if (isset($_REQUEST['ip'])) { $ip = $_REQUEST['ip']; $r = maxmind_lookup($ip); $message = "<table cellspacing=0><tr><td align='right'><b>IP:</b> </td><td><a href='http://whois.domaintools.com/{$ip}'>{$ip}</a></td></tr><tr><td align='right'><b>Country:</b> </td><td>{$r['country']}</td></tr><tr><td align='right'><b>Region:</b> </td><td>{$r['region']}</td></tr><tr><td align='right'><b>City:</b> </td><td>{$r['city']}</td></tr><tr><td align='right'><b>Zip:</b> </td><td>{$r['zip']}</td></tr><tr><td align='right'><b>Lat:</b> </td><td>{$r['lat']}</td></tr><tr><td align='right'><b>Long:</b> </td><td>{$r['long']}</td></tr><tr><td align='right'><b>Metro:</b> </td><td>{$r['metro_code']}</td></tr><tr><td align='right'><b>Area Code:</b> </td><td>{$r['area_code']}</td></tr><tr><td align='right'><b>ISP:</b> </td><td>{$r['isp']}</td></tr><tr><td align='right'><b>Org:</b> </td><td>{$r['org']}</td></tr></table>"; $lat = $r['lat']; $long = $r['long']; } function maxmind_lookup($ipaddress){ global $maxmind_license_key; // Returns:ISO 3166 Two-letter Country Code, Region Code, City, Postal Code, // Latitude, Longitude, Metropolitan Code, Area Code, ISP, Organization. $query = "http://maxmind.com:8010/f?l=" . $maxmind_license_key . "&i=" . $ipaddress; $url = parse_url($query); $host = $url["host"]; $path = $url["path"] . "?" . $url["query"]; $timeout = 1; $fp = fsockopen ($host, 8010, $errno, $errstr, $timeout) or die('Can not open connection to maxmind server.'); $buf = ""; if ($fp) { fputs ($fp, "GET $path HTTP/1.0\nHost: " . $host . "\n\n"); while (!feof($fp)) { $buf .= fgets($fp, 128); } $lines = split("\n", $buf); $data = $lines[count($lines)-1]; fclose($fp); $arrMaxmind = split(",", $data); $arrMaxmind = str_replace("\"", "", $arrMaxmind); $arrMaxmind = str_replace(",", " ", $arrMaxmind); $r['country'] = $arrMaxmind[0]; $r['region'] = $arrMaxmind[1]; $r['city'] = $arrMaxmind[2]; $r['zip'] = $arrMaxmind[3]; $r['lat'] = $arrMaxmind[4]; $r['long'] = $arrMaxmind[5]; $r['metro_code'] = $arrMaxmind[6]; $r['area_code'] = $arrMaxmind[7]; $r['isp'] = $arrMaxmind[8]; $r['org'] = $arrMaxmind[9]; } else { return false; } return $r; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title><?php echo $ip ?></title> <script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $google_maps_key ?>" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.setCenter(new GLatLng(<?php echo $lat ?>, <?php echo $long ?>), <?php echo $zoom ?>); var marker = new GMarker(new GLatLng(<?php echo $lat ?>, <?php echo $long ?>)); marker.html = "<?php echo $message ?>"; GEvent.addListener(marker, 'click', function() {marker.openInfoWindowHtml(marker.html); }); map.addOverlay(marker); marker.openInfoWindowHtml(marker.html); } } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <div id="map" style="width:800px;height:600px"></div> </body> </html>
If you liked my script, post a thanks below.
:)
I am in the process of migrating all SharePoint related blogs to MySharePointBog. The new RSS feed is http://www.mysharepointblog.com/syndication.axd. I am using the fantastic open source BlogEngine.NET from codeplex.com.
I am fairly certain the .NET versioning (numbering release) scheme is the dumbest ever created. Seriously who in their right mind does a point release that is a extension of the previous point but not the one before that (2.0 -> 3.0)? Then 3.0 -> to 3.5? wtf? Remember 1.0 and 1.1? Hmmm. How does that fit in? Oh yea, it doesn’t.
It went like this…
1.0 to 1.1. Perfect. Basically the 1.0 framework fixed with a couple new things. That’s actually how it took place.
Then 2.0. A whole new framework. Yay! We are good at this point.
Then 3.0. Huh? Another new framework? Yay!? Wait, no, huh? It’s not a framework? It’s a extension but only for 2.0 and not related at all to 1.0 or 1.1? Oh good heavens MS.
Then 3.5 Another extension to 2.0 or actually 3.0? Ok, now I’m getting mad. What happened to 3.1, 3.2, etc.?
What’s next? 8.0 with 10.0 extentions?
Might as well number it 38.5. What’s the difference at this point? There is NO consistency anyway and the higher the number the better right?
Anyway here is the 2.0 -> 3.5 relationships…
![]()
Seriously, if you know what the hell MS was thinking, post a comment.
protected void Page_Load(object sender, EventArgs e) { // Show admin link if they have access to the admin directory. // hyperLinkAdmin.Visible = hasAccessToDir("admin"); } protected bool hasAccessToDir(string dir) { return System.IO.Directory.Exists(MapPath(dir)); }
C#
public string CreateADUser(string szUsername, string szDisplayName, string szFirstName, string szLastName, string szMiddleInitial, string szPhone, string szEmail, string szOrgUnit) { string szPassword = "fooBar_123"; //temp only. string szCNName = "CN=" + szUsername; try { DirectoryEntry objContainer = new DirectoryEntry("LDAP://OU=mySubOU,OU=myMainOU,DC=KEVINCORNWELL,DC=com"); DirectoryEntry objUser = objContainer.Children.Add(szCNName.ToLower(), "user"); objUser.Properties["sAMAccountName"].Value = szUsername; objUser.Properties["userPrincipalName"].Value = szUsername + "@KEVINCORNWELL.COM"; objUser.Properties["displayName"].Value = szDisplayName; objUser.Properties["GivenName"].Value = szFirstName; objUser.Properties["sn"].Value = szLastName; objUser.Properties["Initials"].Value = szMiddleInitial; objUser.Properties["mail"].Value = szEmail; objUser.Properties["TelephoneNumber"].Value = szPhone; objUser.Properties["Description"].Value = szOrgUnit; objUser.CommitChanges(); objUser.Invoke("SetPassword", szPassword); objUser.CommitChanges(); int flags = (int)objUser.Properties["userAccountControl"].Value; objUser.Properties["userAccountControl"].Value = flags & ~0x2; //Enable User Account objUser.Properties["pwdLastSet"].Value = 0; objUser.CommitChanges(); return ""; } catch (Exception ex) { return ex.InnerException + ex.Message + ex.Source + ex.StackTrace + ex.Data; } }