README.rst 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. python-pam
  2. ==========
  3. Python pam module supporting py3 (and py2)
  4. Commandline example:
  5. ```
  6. [david@Scott python-pam]$ python pam.py
  7. Username: david
  8. Password:
  9. 0 Success
  10. [david@Scott python-pam]$ python2 pam.py
  11. Username: david
  12. Password:
  13. 0 Success
  14. ```
  15. Inline examples:
  16. ```
  17. [david@Scott python-pam]$ python
  18. Python 3.4.1 (default, May 19 2014, 17:23:49)
  19. [GCC 4.9.0 20140507 (prerelease)] on linux
  20. Type "help", "copyright", "credits" or "license" for more information.
  21. >>> import pam
  22. >>> p = pam.pam()
  23. >>> p.authenticate('david', 'correctpassword')
  24. True
  25. >>> p.authenticate('david', 'badpassword')
  26. False
  27. >>> p.authenticate('david', 'correctpassword', service='login')
  28. True
  29. >>> p.authenticate('david', 'correctpassword', service='unknownservice')
  30. False
  31. >>> p.authenticate('david', 'correctpassword', service='login', resetcreds=True)
  32. True
  33. >>> p.authenticate('david', 'correctpassword', encoding='latin-1')
  34. True
  35. >>> print('{} {}'.format(p.code, p.reason))
  36. 0 Success
  37. >>> p.authenticate('david', 'badpassword')
  38. False
  39. >>> print('{} {}'.format(p.code, p.reason))
  40. 7 Authentication failure
  41. >>>
  42. ```