Active Directory Authentication

Philippe Martin pmartin at snakecard.com
Fri May 5 11:46:26 EDT 2006


Benji York wrote:

> D wrote:
>> Is it possible to have Python authenticate with Active Directory?
>> Specifically what I'd like to do is have a user enter a
>> username/password, then have Python check the credentials with AD - if
>> what they entered is valid, for example, it returns a 1, otherwise a
>> 0..  Thanks!
> 
> Install the Win32 extensions from
> http://starship.python.net/crew/skippy/win32/Downloads.html and do
> something like this:
> 
> try:
>      handle=win32security.LogonUser(username, None, password,
>                    win32security.LOGON32_LOGON_NETWORK,
>                    win32security.LOGON32_PROVIDER_DEFAULT)
> 
>      # We're not going to use the handle, just seeing if we can get it.
>      handle.Close()
>      return True
> except pywintypes.error, e:
>      # Because of the sheer number of Windows-specific errors that can
>      # occur here, we have to assume any of them mean that the
>      # credentials were not valid.
>      return False
> --
> Benji York

I assume then that you can also change user information using the same
principle ? I'm trying to switch some VB6 code to python.

Philippe




More information about the Python-list mailing list