joeware - never stop exploring... :)

Information about joeware mixed with wild and crazy opinions...

5/3/2008

DN Formats in Active Directory (Binding and Search Base)

by @ 7:28 pm. Filed under tech

So Active Directory can do some cool things around distinguishedNames (DNs) that many developers even this long into the availability of the product don’t know or take advantage of. I mention this because yet again I ran into a case where some developer/application integrator was unhappy about how easy it is to move users around in the hierarchy of Active Directory because it made it difficult to bind to the userid…

Now I expect most AD Admins probably don’t think twice about this but anyone who has come from other LDAP directory platforms have a more “that DN better not EVER change” attitude… Why? Because for their bind IDs they need to know the exact DN or else they can’t bind. Trouble that eh?

Bind Formats

So the first thing we will discuss is the “DN” formats available for binding. AD only offers one format that could honestly be called a DN format, but since the term most often used in applications and in general discussion is Bind DN I will stick with the “DN Format” label.

 

Format 1:

An actual real live DN in the normal DN format like CN=joe,OU=Users,OU=My,DC=test,DC=loc. Canonically that looks like test.loc/My/Users/joe. For those who like pretty pics it is this user…

image

With AdFind you could specify this bind DN like so

adfind -default -f name=joe -u cn=joe,ou=users,ou=my,dc=test,dc=loc -up SomePassword123!

Various other programs would have other methods of specifying it, if you use those programs, you should be able to work out the method.

This is the most used/widespread bind DN format for directories and hence applications. For Active Directory it is pretty much your worse choice because it is the most susceptible to breaking. I don’t like to be too direct with things like this but if you don’t know what you are doing, just don’t use this format. It will save you issues later.

 

Format 2:

This is a very familiar format to Windows users and admins as they have lived with it for 15 or more years… However, anyone from some other directory environment will probably look at you in disgust if you mention it… The format is Domain\UserId; this is the standard Windows NT format. So for the previous example the ID would be test\joe. Not only is that shorter, but it has no dependence on the location in the directory where the userID is located, at least within the domain. I could move “joe” to the Domain Controllers OU (not that I normally would) and no programs nor scripts nor tools nor anything else using that Bind DN format would need to be changed.

With AdFind you could specify this bind DN like so

adfind -default -f name=joe -u test\joe -up SomePassword123!

 

Note: If you have but a single domain, it is also safe to omit the [domain\] from the bind DN.

 

Format 3:

This is newer format that neither the old Windows folks nor the old other platform directory folks likely are familiar with. We call it the UPN format because it utilizes the userPrincipalName attribute of the userid. Now this attribute may or may not be populated but whether it is or not, all user’s have a UPN. If nothing specific is specified for a userid, the UPN is their sAMAccountName followed by an @ symbol followed by the domain in dot format. So for the previous example… joe@test.loc. One nice thing about this format is that it *should* work uniquely across an entire forest. So if you move a user even between domains it could be configured to still be fine. But joe… you said it had the domain in the attribute, wouldn’t that change? Well yes reader, if you stick with the default if I move my userid joe from test.loc to child.test.loc then my default UPN will then become joe@child.test.loc but you don’t have to leave the default, you can set what you want… For instance I could set my UPN to actually just be joe@test.loc and regardless of the domain moved to it would stay that way. I could even set it to joe@tracysbarandgrill.com if I wanted to. Of course if you set that value you should also set the allowed (or alternate) UPN Suffixes in the forest to allow for it. That way people can set that suffix in ADUC and so other things with forest trusts all work properly. Strictly speaking for use within a single forest though you don’t need it. You can set the allowed UPN suffixes with domain.msc or you can just go straight to the source and stick it into the uPNSuffixs attribute of CN=Partitions,CN=Configuration,[ROOT DOMAIN DN]

Like so

image

Or better

G:\>adfind -partitions -s base upnsuffixes

AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007

Using server: r2dc1.test.loc:389
Directory: Windows Server 2003
Base DN: cn=partitions,CN=Configuration,DC=test,DC=loc

dn:cn=partitions,CN=Configuration,DC=test,DC=loc
>uPNSuffixes: tracysbarandgrill.com

1 Objects returned

 

So how do you use this format bind DN in AdFind???

adfind -default -f name=joe -u joe@test.loc -up SomePassword123!

 

Note: While Active Directory enforces you to use an email style (RFC 822) format string for the UPN, ADAM (Active Directory Application Mode) does not enforce the same standard. You can use single part strings just fine there such as just joe or joeuser or joe.user.

 

Search Base Formats

Now it is time to discuss the various “DN” formats that can be used for your search base in Active Directory. As you probably know an LDAP query requires you to tell it where in the directory tree to start the search, that is the search base. Most people think you can only specify a DN for this. Normally that may be true but Microsoft was kind enough to give some shortcuts and anyone familiar with AdFind know that I gave more shortcuts but my shortcuts are not the same as the MSFT shortcuts…

 

Format 1:

The first format for the Base DN is, well, not to surprise you too much, but an actual real live DN. This takes the form of any old DN like… to reuse an example… CN=joe,OU=Users,OU=My,DC=test,DC=loc. But since this is about search bases it could be an OU such as OU=Users,OU=My,DC=test,DC=loc.

AdFind Examples:

adfind -b ou=users,ou=my,dc=test,dc=loc -f name=joe

adfind -b cn=joe,ou=users,ou=my,dc=test,dc=loc -s base

 

Format 2:

The next format is the GUID of the object. This is a nice format to use if you are tracking an object and want to be able to go to it wherever it might be moved to within the forest. You specify the base in a special format – <GUID=9e0645e9c606d14295ac153d5076d897>.

AdFind Examples

adfind -b “<GUID=ba1ee8b7248b34408c34841740211a81>” -f name=joe

adfind -b “<GUID=9e0645e9c606d14295ac153d5076d897>” -s base

Those two queries correspond to the queries in the Format 1 examples above.

Note: I had to put quotes around the “DN” because if the great than and less than symbols. Those mean something in the command interpreter and I need them to be passed into AdFind unharmed (see http://blog.joeware.net/2008/03/27/1109/).

 

Format 3

The next format is the SID of the object. This is similar to the GUID format but using SIDs.

AdFind Examples

this space intentionally not an adfind command

adfind -b “<SID=010500000000000515000000aa867905c1c5484bba6236d557040000>” -s base

alternately with any version of Active Directory beyond Windows 2000 you can use

this space intentionally not an adfind command

adfind -b “<SID=S-1-5-21-91850410-1263060417-3577111226-1111>” -s base

 

As you can see, I don’t have a base DN format with the SID specified that I can use for the OU… why you ask? OU’s aren’t security principals and don’t have SIDs (yes I know this pissed you Novell people off – I get it. heh). So no SID, no way to address the OU by SID. As you can also see there are two different SID formats. I won’t go much into this other than yes there are two formats you can use. Most people, if they do this at all, will likely use the second friendly format and not the HEX format.

 

SideBar

There is a little sidebar we can take here now related to these Base DN formats. Microsoft was very kind to allow us to output DNs in such a way that these formats are exposed to us… This is called the extended DN format. It is enabled by turning on the proper LDAP control in the LDAP request, for information see http://msdn.microsoft.com/en-us/library/aa366980(VS.85).aspx or search for LDAP_SERVER_EXTENDED_DN_OID when MSDN breaks that link for me… ๐Ÿ˜‰

So what does that look like you ask?

AdFind Examples

G:\>adfind -default -f name=joe -dn -extname

AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007

Using server: TEST-DC1.test.loc:389
Directory: Windows Server 2003
Base DN: DC=test,DC=loc

dn:<GUID=9e0645e9c606d14295ac153d5076d897>;<SID=010500000000000515000000aa867905c1c5484bba6236d557040000>;CN=joe,OU=Users,OU=My,DC=test,DC=loc

1 Objects returned

And cooler, as you can see, ANY DN format attributes (not to be confused with string attributes that hold DNs) will get output this way…

G:\>adfind -default -f name=joe memberof directreports managedobjects -extname

AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007

Using server: TEST-DC1.test.loc:389
Directory: Windows Server 2003
Base DN: DC=test,DC=loc

dn:<GUID=9e0645e9c606d14295ac153d5076d897>;<SID=010500000000000515000000aa867905c1c5484bba6236d557040000>;CN=joe,OU=Users,OU=My,DC=test,DC=loc
>memberOf: <GUID=f8fcc524dba94047ac67e36d72195747>;<SID=010500000000000515000000aa867905c1c5484bba6236d578060000>;CN=joegroup,OU=joeperm,OU=TestOU,DC=test,DC=loc
>directReports: <GUID=7806a7be8d6d094b9f9750143cc5151a>;<SID=010500000000000515000000aa867905c1c5484bba6236d5f4010000>;CN=Administrator,CN=Users,DC=test,DC=loc
>managedObjects: <GUID=6186a268b84c374c8563baf56e387d3f>;<SID=010500000000000515000000aa867905c1c5484bba6236d505020000>;CN=Cert Publishers,CN=Users,DC=test,DC=loc

1 Objects returned

And here is an example of the same output for an OU, note the lack of the SID field

G:\>adfind -default -f ou=users -dn -extname

AdFind V01.37.00cpp Joe Richards (joe@joeware.net) June 2007

Using server: TEST-DC1.test.loc:389
Directory: Windows Server 2003
Base DN: DC=test,DC=loc

dn:<GUID=ba1ee8b7248b34408c34841740211a81>;OU=Users,OU=My,DC=test,DC=loc
dn:<GUID=d64d7146973a5a4b928403fba911fb63>;OU=Users,OU=TestOU,DC=test,DC=loc

2 Objects returned

Rating 4.00 out of 5

Upgraded WordPress

by @ 7:21 pm. Filed under updates

So I did something I always have some amount of trepidation doing… upgraded my web software, in particular I upgraded WordPress. This was needed, there was a security issue in the older version I was using and someone actually poked themselves into it and popped some hidden links into the blog entries. No harm to you, no fears. Just pissed me off.

So if you see anything weird, let me know.

   joe

Rating 3.00 out of 5

Gorgeous

by @ 4:53 pm. Filed under general

butterfly_yellow-flowers

Rating 3.00 out of 5

Why I have a headache today…

by @ 11:39 am. Filed under general

Now this is an evil weather front system…

 

image

Rating 3.00 out of 5

5/2/2008

And another movie that looks good…

by @ 6:46 pm. Filed under general

My inner geek is coming out again…

Looks like they may have done it correctly this time. Though no one has yet to have properly explained to me why his pants stretch so much… I gain a few pounds and my pants rip right out in the crotch darn near every time. ๐Ÿ˜‰

 

image

image

 

 

 

 

Better Quality Trailers here – http://www.apple.com/trailers/universal/theincrediblehulk/

Rating 3.00 out of 5

5/1/2008

Things are looking up in Chile…

by @ 11:27 pm. Filed under humour

http://ap.google.com/article/ALeqM5gsPiYvAUO3i7krLIdN-nv09fxkvQD90CE08O0

 

Chilean town giving free Viagra to senior citizens

SANTIAGO, Chile (AP) รขโ‚ฌโ€ A working class suburb of Chile’s capital began handing out free Viagra to senior citizens on Wednesday. Lo Prado Mayor Gonzalo Navarrete said he launched the program because “an active sexuality improves the overall quality of life.”

About 1,500 residents of the working-class area are eligible to receive as many as four pills of the erectile dysfunction drug each month, the mayor said. They have to be at least 60 and be registered with the municipality’s health service.

“A doctor will have to certify that they suffer from erectile dysfunction and that their condition would not put them in danger of suffering cardio-respiratory side effects,” Navarrete told The Associated Press by telephone.

He said he has assured about US$10,000 (euro6,400) in financing for the program through the end of the year.

Some government insurance plans in the United States and elsewhere provide Viagra, but Lo Prado hands the 50mg pills out free, with no membership in any public or private insurance plan required.

Navarrete said some other mayors in the Santiago area, which includes 34 municipalities, have told him they plan similar programs.

Navarrete said he did not know how many pills had been distributed so far.

Rating 3.00 out of 5

4/29/2008

Kudos to the Microsoft Exchange Dev Team…

by @ 11:46 pm. Filed under tech

I know some of you may read that and choke on your bagel or candy bar or coke or whatever else you were shoving down your throat as you relaxed and sat back to read what I have to say today…

But I mean it!

I had an unfortunate issue where one of my virtual host servers started having issues with one of the Western Digital drives in it. This particular drive was in a MOBO RAID (Promise RAID) "stripe" set.  This caused my server to act quite erratically and black screen (like a blue screen of death but worse because you have nothing to go on) and generally perform poorly. After a series of tests I worked out what happened. Unfortunately both my Exchange Server and my mail client machines were virtuals on that one host… So I lost Exchange and all of my PSTs in one fell swoop. I was devastated as you may imagine. Well you may not imagine it all… When I moved, my backup system "broke" and I never reset it all up. It was one of those, "I will get to it" items. Well busy schedule and Carbon Monoxide poisoning prevented me from worrying about it and voila, several months later, here I am with broken pieces and a need for a backup but that backup was almost 6 months old…

Long story slightly shortened, the Promise RAID "Stripe" set apparently wasn’t a stripe set because I noticed while trying to copy files off, some worked fine, some didn’t work as fine and actually hung the box. So I worked to get as much off as possible and soon realized that the symptoms added up to the "Stripe" set where the data is interspersed on both drives equally in stripes (hence the brilliant name) was actually implemented as a volume set… I.E. The info was written to one drive and then slowly crawled onto the second. Luckily, 3 DCs and my client’s Data logical virtual drives were all on the "good" disk and the Exchange server, one DC, and my client’s OS disk logical virtual drives were on the "bad" disk. Using the command line virtual disk mounting tool in Virtual Server I mounted my client data virtual disk and immediately copied the gigs and gigs of PSTs off and to about 10 different other machines. ๐Ÿ˜‰

So only thing left was to rebuild a DC and the Exchange Server… Well I wasn’t relishing the Exchange Server rebuild as I had a lot of custom settings… Well my good friend and coworker and co-MVP buddy old pal Brian Desmond casually said in IM… why don’t you just use "setup /disasterrecovery" (dumbass)[1]. I was like… hmmm never heard of it, my Exchange servers don’t do that normally. Let me try it…

WOW. Very cool. I was very impressed. Worked like a dream. I was, at that moment, thinking, hey the Exchange team did something right here. I was quite happy as all special configs I had were all in place and bam things just worked. Very good.

Of course if I look on this in the slightly negative way I could say… why is it that one of the best implemented features I have found to date was the disaster recovery option??? Have to run that much around the world?  I will just assume they thought it was exceedingly important to get right and exceedingly easy to do because all of the data was in AD already. I am glad it ran that well. If it didn’t, it is quite likely I would be running a FreeBSD mail server right now because honestly, Exchange is running in my house for two reasons. First, it is for testing things to see how it impacts AD and of course for my ExchMbx utility and second, I need a SMTP/POP3 landing zone server and that is all it is.

 

BTW, some folks I consider to be  good friends now are over on the Exchange Dev team and I know we will see amazing things because of it. I look forward to when their influence is helping us all out.

 

    joe

 

 

[1] Brian didn’t say dumbass, I just inferred it from how it was said. ๐Ÿ˜‰

Rating 3.00 out of 5

For anyone NOT familiar with Eddie Izzard

by @ 11:44 pm. Filed under humour

 

 

 

 

 

 

 

 

 

 

 

 

Rating 3.00 out of 5

Ohhhhhhhhh 2

by @ 10:31 pm. Filed under general

So maybe not a complete geek, this looks good too.

 

Deception…

 

Rating 3.00 out of 5

Ohhhhhhhhhhhhhhhh

by @ 10:25 pm. Filed under general

Yes I am a geek….

 

Iron Man the Movie!!!

 

 

Iron Man Trailer

 

http://www.myspace.com/ironmanmovie

Rating 3.00 out of 5

[joeware – never stop exploring… :) is proudly powered by WordPress.]