Gollor's Glimmering Edification in IT
Bits and pieces of IT lore I discover, pick up, find or steal.
Wednesday, March 28, 2012
SqlDataSource Selected Event Not Firing
Ran into this today when I was using the SqlDataSource and ListView to look up users based on one of three parameters, where I expected at least one of them to be null. I didn't expect the seemingly weird behavior when my ListView kept showing up empty, but the query with the same parameters worked just fine.
Props to Christopher for posting about this one, and helping me find a clue.
TL;DR - you have to set the CancelSelectOnNullParameter to false, if you want to pass null parameter values, or the query will get cancelled before it even starts.
Tuesday, March 27, 2012
Doing Queries Against Active Directory using SQL Server 2005
Four basic steps:
1. Setup a linked server to the object that translates your queries into something active directory can recognize.
2. Add security to the linked server, active directory users with permissions to query
3. The more important step that most blogs didn't cover - setup ad hoc distributed queries on the SQL Server instance you're using this linked server on.
4. Run your sql queries against the linked server using the right SQL protocol/LDAP syntax.
1. Setup linked server
You can use the UI to create a linked server object, but I generally prefer using sql command wherever I can so I have a file of stuff I did with notes. That way I know how to do it again, 3 years later when someone else wants to me to do it. The sql server sytnax for settting up the linked server to active directory is this:
EXEC sp_addlinkedserver 'ADSI', 'Active Directory Services 2.5', 'ADSDSOObject', 'adsdatasource'
2. Setup security to linked server
You have to use an domain account with the rights to at least peer into active directory. You can generally test this with something like SysInternals ADExplorer. That tools and others like it are handy for exploring the hierarchy of active directory and the properties you have available for queries. Again I used sql to set this up, but you can also use the security properties of the linked server once you set it up:
EXEC sp_addlinkedsrvlogin 'ADSI', true, '<domain>\<account>';
3. Turn on the ad hoc distributed queries property
This was a tricky step to find as I said, which is why I'm adding my voice to the two tiny screams in the vast bowels of the internet. Supposedly you can turn this on in the SQL Server Surface Area Configuration wizard, but neither I nor my DBA could find it. We found an "Ad hoc queries" option that could be turned on, but this is apparently NOT the same thing. We had this turned on already on the server in question and my queries thru the ADSI linked server still failed with the error: "an error occured while preparing the query". To turn this option on use:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ad Hoc Distributed Queries', 1;
GO
RECONFIGURE;
GO
4. Run your sql queries against the linked server
We needed to get information about users in our domain so we used this query:
SELECT *
FROM OpenQuery(ADSI,
'SELECT givenname, initials, sn, mail, telephonenumber, displayName
FROM ''LDAP://<server>:389/dc=<your>,dc=<domain>''
WHERE objectClass = ''user''
');
Originally we were trying to get this information from our eDirectory identity vault, since we still have that ol' monstrosity left over from when it was handling everything. However, this does NOT work with the SQL Server ASDI linked server. At least we couldn't get it to work - you get this error with the returned data:
Cannot get the data of the row from the OLE DB provider
"ADSDSOObject" for linked server "ADSI". Could not convert the data value due to
reasons other than sign mismatch or overflow.
Monday, December 27, 2010
If an alien invasion really happened, we'd be dead instantly?
Depressing and realistic? Or just pessimistic. Assuming aliens would want to come here in the first place, why would they? For materials? Why the heck would they travel light years for that just to grab some metals or gasses they can likely find in any star system.
I suppose it's possible they might just wipe us out, but in all the vastness of space there is really only one thing that could draw aliens here. They would come for same reason we want to visit other worlds - life. Life has to be the most precious thing in the universe. Even if life is abundant, and on ever planet in a mostly habitable zone around a star, the universe is so vast as to still make it scarce and amazing.
It seems most likely there would have to be something about us that they would want to exploit that would make the trip worth all the bother and expense. Maybe they want a client race to be slaves, we've already found that machines are damn hard to build that can do something as good as a human can do, except with very particular specializations. Possibly they have a need to be worshiped (Stargate). Instead, they may simply need to be in control of that most precious thing the universe can offer.
It could be there is something unique about life itself that they can devour or fuel their technology with(Vampire Earth, The Matrix). Perhaps the worst scenario maybe they are so xenophobic they simply can't abide anything that lives besides them(Berserkers). Most hopeful - they could want to better us...for a price (Uplift Saga).
Perhaps, as in Star Trek, beings would seek to make common cause with other beings for mutual protection and comfort in the face of more hostile aliens. However, as with the prime directive there are limits to the usefulness of non-spacefaring races. Plus, such races would be extremely vulnerable to exploitation and destruction by more advanced species. In the context of a larger arena of political games we might be wiped out, or enslaved just because another race might find us a convenient choke point or jump off point between them and their neighbors.
It's damn hard to predict what something with an alien biology and psychology would want or need, but it seems likely it would have to revolve around life.
Read more at io9.com
In movies humans fight off alien occupation forces, explode alien ships, and mind-control aliens with the power of love. How on earth can we think that would happen?
Friday, July 23, 2010
Words to live by: advice from 34 science fiction/fantasy authors
Some of the less well-trodden words of wisdom, since everyone has been flooded with Heinlein and Dune quotes since the dawn of the internet. Love that one from Pratchett. Reminds me of the classic skit from Bill Cosby:
My father established our relationship when I was seven years old. He looked at me and said, "You know, I brought you in this world, and I can take you out. And it don't make no difference to me, I'll make another one look just like you."
Words to live by: advice from 34 science fiction/fantasy authors
Great science fiction and fantasy novels don't just expose us to other worlds and alternate timelines — they expand our minds and give us compass to steer by. Here are our favorite bits of advice and maxims from SF books.
You could do a lot worse than living your life according to principles espoused in science fiction books — in fact, here's somebody who claims that it's impossible to live a moral life unless you read science fiction. We won't go quite that far, but here are some words to live by from science fiction. Please do post your own favorite maxims and aphorisms from SF in the comments — I have a feeling it'll be a really amazing comment thread!
"Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." — Sir Terry Pratchett.
Read more at io9.com
Tuesday, May 19, 2009
For Pascal fans who are forced to muddle thru the joys of C#
The old Pascal syntax was:
if (i in [1,3,5..10])
The fun little shorthand in C#:
if (Array.IndexOf(new int[] { 1, 3, 5, 10 }, i) != -1)
Thanks, Larry Smith.
Thursday, May 14, 2009
The suckiness of mornings has been made more clear to me
However, I hate traffic even more. Or really to put it more accurately, I hate what people do in their cars when they are rushing off to work in the morning. Especially when they try to kill me.
I was reading in the news, yesterday, about HR 45, a bill to put more regulatory burden on the people who already buy guns legally, above board in gun stores and at gun shows. "The Centers for Disease Control and Prevention (CDC) estimating 52,447 deliberate and 23,237 accidental non-fatal gunshot injuries in the United States during 2000." - Wikipedia.
Traffic accidents accounted for 43,000 deaths in 2000 - Wikipedia. I'm much more afraid that some knucklehead will decide to lane change while I'm passing thru his blind spot, or some ass-munch will decided he can make his left turn before I can get to the intersection.
So I get up early...leave before the morning rush hour starts, and so I can leave before the afternoon rush hour starts. I'm still evaluating which one causes me more stress. In the meantime it's time for caffeine.