Showing posts with label solaris. Show all posts
Showing posts with label solaris. Show all posts

Saturday, April 10, 2010

Samba4 AD Domain Controller to serve Solaris and Windows

The installation of Samba4 as DC is almost finished. Despite some minor issues and a bit of work involved it was a rather pleasant and nice thing to do. I try to document the steps I had to do here as a little reference. Implementing Linux clients is still open, so for now this is very Solaris centric. But should be easy to reproduce on Linux.

Start off with the Samba4 how-to here. It gives all information needed to build and setup your DC. Once this is completed you are ready to serve Windows clients.
But I want to do a little bit more and use the data in Samba4's LDAP to serve the Unix boxes as well.

For wide parts I followed Scott Lowe's post on integrating Solaris 10 and Active Directory.
Since a few things differ when using Samba4 as AD I'll list the steps with short comments here again:

I skipped the part about installing the "Server for NIS" on the AD server. When I started off setting things up I didn't the schema use by AD and SFU at hand. But you only need that if you plan to manage you users with the MS tools (MMC and the likes). Since I tend to do that stuff from my Solaris box with a few scripts I found the presence of the posixAccount and shadowAccount objectclasses sufficient. As it turns out the need schema for the SFU stuff can be found here.

I created a test account with

net newuser test password

and set the required attributes with ldapmodify:

ldapmodify -h ldapserver -D adminsitrator@YOURDOMAIN
dn: cn=test,cn=users,dc=YOURDOMAIN
changetype: modify
add: objectclass
objectclass: posixaccount
-
add: objectclass
objectclass: shadowaccount
-
add: uidnumber
uidnumber: 1000
-
add: gidnumber
gidnumber: 100
-
add:unixhomedirectory
unixhomedirectory: /home/test
-
add: loginshell
loginshell: /bin/tcsh

This will be done with a litte script later, including creating a ZFS dataset for the user, finding the next free uidnumber and so on. For now this is just fine.

Well almost perfect. Unfortunately the MS AD schema used by Samba4 doesn't know anything about automount maps. So I had to add the necessary schema.
The schema definition is here. This creates an auto_master map with entries for /net and /home and the auto_home map with an entry for
* fileserver:/export/home/&
autmount.ldif can be added using ldapadd. The creation of the actual maps with ldapadd fails though. It gives a naming violation and I haven't found out why yet. Luckily Samba4 brings ldbmodify that can process LDIFs and write them into the database.
Point it to the ldb file for your domain. (Those files are in $SAMBAHOME/private/sam.ldb.d/ ):
ldbmodify -H $SAMBAHOME/private/sam.ldb.d/DC%3DYOURDOMAIN.ldb -U administrator autmount_maps.ldif
You may want to make a backup before ;-)

Next thing is to setup Kerberos. For that to work we need to create service principals in the Kerberos database for each host that we want to join.
Scott's post suggests to create an user account for each Solaris machine and to use ktpass.exe to generate a keytab file. Since I couldn't find a version of ktpass that would work on the Windows7 (virtual machines) I have here, I reverted to an alternative way. The easiest was to just use Samba3 and join the machines as domain members using a minimal smb.conf with
workgroup = DOMAIN
realm = REALM
security = ADS

When you have the smb.conf in place do the basic Kerberos setup on your Solaris client. Either use kclient to configure everything or copy the krb5.conf from your S4 DC. That file is created during the provision and can be found in $SAMBAHOME/private/krb5.conf. krb5.conf goes into /etc/krb5 on Solaris.
Test your Kerberos setup with
kinit administrator@REALM (mind the uppercase for the realm). That should exit without failure. You can check your ticket with klist.
If that worked you can now do a
net ads join -U administrator
to join the domain. Upon a successful join we can use
net keytab create
to write the principal key into a local file. The Samba3 that comes with Solaris10 writes the krb5.keytab in /etc. The Solaris Kerberos client expects that file to be in /etc/krb5 though. So just move it there.
Now we have Kerberos configured and the needed keytab in place.
Tell PAM to use Kerberos for authentication by modifying /etc/pam.conf to look like this:

other auth requisite pam_authtok_get.so.1
other auth required pam_dhkeys.so.1
other auth sufficient pam_krb5.so.1
other auth required pam_unix_cred.so.1
other auth required pam_unix_auth.so.1


The last missing piece is the LDAP configuration. For now I trimmed down the ldapclient line from Scott's post to;
ldapclient manual \
-a defaultSearchBase=dc=example,dc=com \
-a domainName=example.com \
-a defaultServerList=172.16.1.10 \
-a attributeMap=passwd:gecos=cn \
-a attributeMap=passwd:homedirectory=unixHomeDirectory \
-a serviceSearchDescriptor=passwd:cn=users,dc=example,dc=com \
-a serviceSearchDescriptor=group:cn=users,dc=example,dc=com

Problem is that this expects the users to have objectclass posixAccount and shadowAccount (no problem for me, since I set those in my scripts). The windows tools only set objectclass user (see the objectClassMap in Scott's post).
I tried with that mapping in place, but found that getent passwd fails to list LDAP users, getent passwd username works, finger fails, logins work. I assume there is something wrong with getent in Solaris but I need to investigate a litte more.
Without the objectclassmap in place everything works just fine.
One advise - ldapclient copies /etc/nsswitch.ldap to /etc/nsswitch.conf. So go and check that file, especially look at the hosts line. You sure want DNS in there... ;-)

Now users can login with their domain accounts and have a common password for both Windows and Solaris.
I need to play around with the mappings a little more and get a few more maps into LDAP (auth_attr, prof_attr and project at least). Also at the moment I cannot change the password from a Solaris client.
Let me know If you need more details on the bits of the setup, I'll try to help.

Tuesday, December 23, 2008

Moving box to S10U6 with ZFS root

So what do you do just before christmas? Well I started updating a T1000 from Solaris 10U4 to U6 with ZFS root. As this box serves a patient administration system in a hospital there is not much room for longer down times. Well except around official holidays.
The T1000 is a nice box to run databases on boot it has one problem - not a real problem more like a hurdle in terms of updating. It came with just a single hard disk when we got it. It has a StorEdge 3510 attached though.
Well sounds quite easy. Setup LiveUpgrade and off you go. In theory yes. Creation of the new boot environment worked nicely. Upgrade went fine too. The damn thing just wouldn't boot off the external disk stack. Bugger.
As there are now double disks in a single bracket available (well for some time now) I ordered a pair of disks to move the installation from one disk to the new pair.
Now the dirty part begins ;-)
As I am too lazy to replicate the installation from scratch (I could do it but it would require more time than I have at hand) I chose the adventurous route ;-)
  • First of all dump the current installation to the external disk stack.
  • Swap the disks.
  • Boot off the net (the T1000 doesn't have a DVD drive and I didn't want to try an USB drive)
  • Slice one of the new disks as desired
  • Restore the dump from the external disks
  • Reboot
  • Be done.
Well not quite.
  • Booting fails as I forgot to run installboot on the new disk, so boot net again
  • Install the boot block on the new drive with installboot
  • Reboot
  • Done
Works nicely. Including all copying (roughly 30GB local data), net booting etc the box was running again in less than 2 hours.

What's next?
Create a new boot environment on the second disk. As we are still running S10U4 it has to be UFS again. Right now it is still populating the new BE with data from the first disk. (Yes, we are running live at this point.) Luckily the new disks (SATA vs SAS) are much faster, so this is running faster than expected.
Next thing will be the update to S10U6 followed be reboot into the new BE running S10U6. That gives us ZFS root. Once this is done and working I'll delete the first BE and create a new boot environment on a ZFS root pool. And one last reboot will bring us to where we want to be. Mirror root pool with much easier upgrade procedures next time (and just a single reboot needed).

Update
The upgrade to S10U6 took a bit over 2 hours. No problems here. Try to boot the new BE.
With the shutdown running I knew there was something missing.
Exactly.
The luactivate. Things like this happen when you drive home (90min commute) to finish this from home. Oh well!
Anyway, activated and booted the new BE.
Zpool created (remember it has to be a slice in order to be bootable! - Yes I did read the man page on that point ;-))
So now we are copying the S10U6 UFS BE to the final destination on a zpool.

Update 2
Everything made it to the new BE on the zpool. It boots. This was work for today then.

Merry Christmas everyone!