Peter's Blog

Redefining the Impossible

Validating users


For a long time now I have been contemplating how to validate users on a linux box against a Windows 2000 Active Directory domain. What I mean is, how to use the user names and passwords from the Windows server, without having to set up a duplicate password database on the linux box? I had been under the impression that this meant setting up a linux ldap server and migrating everything to that (as the Windows 2000 version of ldap is deliberately non-interoperable).

Been into it again today and discovered that from python it is actually very easy to validate via python samba support:

import samba.winbind

try:
    if samba.winbind.auth_plaintext( 'Domain\\%s' % strUser, strPassword) != 0:
       raise 'login failed'
except(samba.winbind.error):
    raise 'login failed'

Samba finds the domain controller and validates the user name and password. What could be easier?

This is fine for intranet activities but if you want users logging into your linux box you have to go the ldap route to give them unix groups, login shells etc. Good luck with that.


Filed under: linux python

Anonymous Says:

over 2 years ago

Or, instead of LDAP you could just use PAM and winbind: http url-> quark.humbug.org.au/publications/notes/winbind.txt

Since using LDAP requires use of PAM anyway.

Peter Says:

over 2 years ago

This looks like a useful tip for more advanced stuff. My simple verification has been working quite nicely though. When people cannot log in it is invariable because their Active Directory accounts have been locked out due to finger trouble. The authentication mechanism has not failed thus far (and I hereby consider fate tempted).

Peter

Have Your Say

I welcome constructive comments or questions but I reserve the right to delete any comments that displease me.

Who are you?

(Optional) If you enter an email address here I might email you back. Your email address will not be sold to spammers or shown anywhere

What do you have to say?