10.22.2007

understanding ADAM

Here's a very pedagogic article about ADAM (ok, AD LDS) by Brian Redmond.
Interesting stuff, specially the scenarios, I think they are described in a very simple and understandable way.

White pages directory: use syncro tools to pull data from AD, SQL, etc to ADAM. Then the App talks only to ADAM.

Application-specific: the app needs attributes that are not in the AD schema. Authentication is done against AD but for additional info LDAP queries are made against ADAM

Extranet Authentication: provides web SSO

Legacy LDAP & Bind redirection: for apps that connected to LDAP directories. We replace them with ADAM (after migrationg data form old LDAP to ADAM). In case of Bind redirection, we create in ADAM a userProxy that represents an AD account.

ADAM with SSL

Ok, it may take some time to make it work. Luckily there's quite a lot of info posted by others who spent days trying to do it properly.

Here's erlend's post with detailed instructions.
Includes all the Certificate Authority stuff that is required.

And here's tom's post with some tips if you have the classical “8009030d The credentials supplied to the package were not recognized” error.

10.20.2007

Identity in .net

Ok, security is one of your main concerns if you work in something more than just atoy application. This article by Keith Brown covers Authentication, Single-Sign-On, Authorization, Azman stuff, federated identities, principals, ADFS, and security in WCF. Too much you might say, but after reading this i think you get the hole picture of security in the .net framework. What you can do and what you can't (o, everything is possible....)

10.07.2007

What's on SQL Server's data buffer?

SQL Server stores data on 8K pages. These pages can be data pages, index pages and others (here you'll find the complete list). These pages (well, some of them at a given time) can be stored on the data buffer of SQL Server. Obviously this is because it is faster to retrieve pages from the buffer (RAM) than from disk (physical access).

But sometimes one asks what's being stored right now in the buffer? We should trust SQL Server's Buffer management policies, but it's better to know exactly what's going on inside. This article by Bill Graziano can be very useful if you need to know....

SQL Server Performance counters

As usual, the guys from SQL Performance have good tips. this time it's about performance counters. They are very useful if you want to monitor some specific event on your db server, examples:

SQL Server Access Methods object: Page Splits/sec:
SQL Server Buffer Manager Object: Cache Size
SQL Server Buffer Manager Object: Buffer Cache Hit Ratio.
SQLServer: SQL Statistics: Batch Requests/Sec
SQLServer: SQL Statistics: SQL Compilations/Sec counter.
SQL Server General Statistics Object: User Connections
SQL Server Locks Object: Number of Deadlocks/sec


More info here

9.26.2007

deadlocks in SQL Server

In some nasty occasions, we find this kind of exceptions after a batch of transactions has been executed in sql server:

Transaction (Process ID 78) was deadlocked on lock resources with another
process and has been chosen as the deadlock victim. Rerun the transaction.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlExcept
ion: Transaction (Process
ID 78) was deadlocked on lock resources with another process and has been
chosen as the deadlock victim. Rerun the transaction.


There is a quite complete article on the subject by Ron Talmage. I just cite some important statements:

"Lock-based deadlocks involve two or more threads, at least one transaction, and one or more resources. It's useful to view deadlocks as occurring in two stages. The first is a grant stage, where each thread is granted a lock on its resource.[...]The second stage is a blocked request where each thread requests an incompatible lock on the other thread's resource. Each thread waits on the other to release its locks before it can complete."
When SQL Server finds deadlocks, it proceeds to choose one of the threads as the "victim" and kills it (well, rols back its transaction).

The article explains 4 main ways to solve deadlocks:
  • Remove incompatible lock requests
  • Change the timing of transactions
  • Change the order of resource requests
  • Change the isolation leve

The last one, changing the isolation level, seems to be the only way in some cases. For example, if we allow queries to read uncommitted data, we can set the level as follows:

SET ISOLATION LEVEL READ UNCOMMITTED

So next time you have one of those, this article might help.

9.25.2007

SQL Server hierarchyid

Sometimes we're in the need of representing hierarchical data in a database. Take the example of a Military structure:

General Mihajlovic
|- Colonel Stojakovic
|- Lieutenant Mijatovic
|- Sgt Milinkovic
|- Colonel Dragutinovic
|- Lieutenant Djokovic


One way to store this in tables would be to create a table 'Military Person' with a 'parent' id, where every tuple references its 'father' in the hierarchy.

In Sql Server 2008 there is a new datatype called hierarchyid, that might help in this case. The hierarchyid stores the hierarchical information of a tuple. It is in fact a CLR User-defined type (UDT) but is included in the set of base types of sql server.

The string representation of a hierarchyid field looks something like: '/1/2/'
The slashes '/' represent levels in the hierarchy and the numbers, e.g. '1' denotes the position of the child. So the root of the hierarchy is represented by the slash alone: '/'

For instance the military structure described above could be codified as:

/General Mihajlovic
/1/ Colonel Stojakovic
/1/1/ Lieutenant Mijatovic
/1/1/1/ Sgt Milinkovic
/2/ Colonel Dragutinovic
/2/1/ Lieutenant Djokovic


The hierarchyid type exposes several useful method such as GetLevel(), GetAncestor(), GetDescendant(), GetRoot(), Parse(), etc.

So take a look at this link, there are some examples,
and maybe this one as well,
and you can replay the recording of the LiveMeeting

9.18.2007

Schemas in SQL Server 2005

Although this is not really new (2 years on), it's good to know. Schemas in SQL Server are some kind of "containers of objects" (tables views, etc.)
In this way we are able to specify namespaces for our objects for better organization, and, most imimportant, better security management.

In previous versions of SQL Server, an object name was something like:
DBServer.DBName.Owner.Object, but now it is DBServer.DBName.DBSchema.Object

So now the objects are not bound to a particular DB Owner. In consequence if we want to drop some owner, we don't need to drop all the objects defined under its name.

Official info right here

More useful stuff over here

9.04.2007

HL7 v3 Datatypes release 2

The HL7 v3 Comitee ha published the first draft of Release 2 for HL7 datatypes. It is still a draft but there are a number of interesting changes.

One of them concerns translation of concept labels and names.

The ED and its specialization ST (string) have now a SET of ED/ST called "translation".
This means that any attribute of type ST may have a set of other STs, each one representing a translation in a different language. (the ST type already had a language field if I remember well)

more details at the ballot page: Ballot September 2007

and some comments at the wiki: HL7 wiki


Now we have to see what the comitee decides about these datatype issues...