python-win-ad 0.6.2__tar.gz → 0.6.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/PKG-INFO +4 -3
  2. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/__init__.py +4 -0
  3. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/adbase.py +6 -3
  4. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/adobject.py +4 -2
  5. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/python_win_ad.egg-info/PKG-INFO +4 -3
  6. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/python_win_ad.egg-info/SOURCES.txt +3 -1
  7. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/setup.py +2 -3
  8. python_win_ad-0.6.3/tests/tests_adbase.py +22 -0
  9. python_win_ad-0.6.3/tests/tests_adquery.py +53 -0
  10. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/LICENSE +0 -0
  11. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/README.rst +0 -0
  12. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/adcomputer.py +0 -0
  13. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/adcontainer.py +0 -0
  14. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/addomain.py +0 -0
  15. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/adgroup.py +0 -0
  16. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/adquery.py +0 -0
  17. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/adsearch.py +0 -0
  18. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/aduser.py +0 -0
  19. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/pyad.py +0 -0
  20. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/pyadconstants.py +0 -0
  21. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/pyadexceptions.py +0 -0
  22. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/pyad/pyadutils.py +0 -0
  23. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/python_win_ad.egg-info/dependency_links.txt +0 -0
  24. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/python_win_ad.egg-info/requires.txt +0 -0
  25. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/python_win_ad.egg-info/top_level.txt +0 -0
  26. {python-win-ad-0.6.2 → python_win_ad-0.6.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-win-ad
3
- Version: 0.6.2
3
+ Version: 0.6.3
4
4
  Summary: An Object-Oriented Active Directory management framework built on ADSI
5
5
  Home-page: https://github.com/jcarswell/pyad/
6
6
  Author: Zakir Durumeric
@@ -17,14 +17,15 @@ Classifier: Natural Language :: English
17
17
  Classifier: Operating System :: Microsoft :: Windows
18
18
  Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
19
19
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.6
21
- Classifier: Programming Language :: Python :: 3.7
22
20
  Classifier: Programming Language :: Python :: 3.8
23
21
  Classifier: Programming Language :: Python :: 3.9
24
22
  Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
25
24
  Obsoletes: pyad
26
25
  Requires-Python: >=3.6
27
26
  License-File: LICENSE
27
+ Requires-Dist: setuptools
28
+ Requires-Dist: pywin32
28
29
 
29
30
  .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
30
31
  :align: center
@@ -1,3 +1,7 @@
1
+ # package logger
2
+ import logging
3
+ logging.basicConfig(level=logging.WARNING)
4
+
1
5
  __all__ = [
2
6
  "set_defaults",
3
7
  "ADQuery",
@@ -1,17 +1,20 @@
1
+ import logging
1
2
  import sys
2
3
  import win32com.client
3
4
 
4
5
  from .pyadexceptions import SetupError
5
6
 
7
+ logger = logging.getLogger(__name__)
6
8
  _adsi_provider = win32com.client.Dispatch("ADsNameSpaces")
7
9
 
8
10
  try:
9
11
  # Discover default domain and forest information
10
12
  __default_domain_obj = _adsi_provider.GetObject("", "LDAP://rootDSE")
11
13
  except:
12
- # If there was an error, this this computer might not be on a domain.
13
- print(
14
- "WARN: unable to connect to default domain. Computer is likely not attached to an AD domain"
14
+ # If there was an error, this computer might not be on a domain.
15
+ logger.info(
16
+ "Unable to connect to default domain. "
17
+ "Computer is likely not attached to an AD domain."
15
18
  )
16
19
  __default_domain_obj = None
17
20
  _default_detected_forest = None
@@ -1,3 +1,4 @@
1
+ import logging
1
2
  import win32com
2
3
  import pywintypes
3
4
  import time
@@ -16,6 +17,7 @@ from .pyadconstants import (
16
17
  ADS_USER_FLAG,
17
18
  )
18
19
 
20
+ logger = logging.getLogger(__name__)
19
21
 
20
22
  @total_ordering
21
23
  class ADObject(ADBase):
@@ -664,7 +666,7 @@ class ADObject(ADBase):
664
666
  )
665
667
  node.appendChild(text)
666
668
  except:
667
- print("attribute: %s not xml-able" % attribute)
669
+ logger.error("attribute: %s not xml-able" % attribute)
668
670
  else:
669
671
  node.setAttribute("type", "multiValued")
670
672
  ok_elem = False
@@ -684,7 +686,7 @@ class ADObject(ADBase):
684
686
  node.appendChild(valnode)
685
687
  ok_elem = True
686
688
  except:
687
- print("attribute: %s not xml-able" % attribute)
689
+ logger.error("attribute: %s not xml-able" % attribute)
688
690
  if ok_elem:
689
691
  adobj_xml_doc.appendChild(node)
690
692
  return doc.toxml(encoding="UTF-8")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-win-ad
3
- Version: 0.6.2
3
+ Version: 0.6.3
4
4
  Summary: An Object-Oriented Active Directory management framework built on ADSI
5
5
  Home-page: https://github.com/jcarswell/pyad/
6
6
  Author: Zakir Durumeric
@@ -17,14 +17,15 @@ Classifier: Natural Language :: English
17
17
  Classifier: Operating System :: Microsoft :: Windows
18
18
  Classifier: Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP
19
19
  Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.6
21
- Classifier: Programming Language :: Python :: 3.7
22
20
  Classifier: Programming Language :: Python :: 3.8
23
21
  Classifier: Programming Language :: Python :: 3.9
24
22
  Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
25
24
  Obsoletes: pyad
26
25
  Requires-Python: >=3.6
27
26
  License-File: LICENSE
27
+ Requires-Dist: setuptools
28
+ Requires-Dist: pywin32
28
29
 
29
30
  .. image:: https://img.shields.io/badge/code%20style-black-000000.svg
30
31
  :align: center
@@ -19,4 +19,6 @@ python_win_ad.egg-info/PKG-INFO
19
19
  python_win_ad.egg-info/SOURCES.txt
20
20
  python_win_ad.egg-info/dependency_links.txt
21
21
  python_win_ad.egg-info/requires.txt
22
- python_win_ad.egg-info/top_level.txt
22
+ python_win_ad.egg-info/top_level.txt
23
+ tests/tests_adbase.py
24
+ tests/tests_adquery.py
@@ -12,7 +12,7 @@ def read(fname):
12
12
 
13
13
  setup(
14
14
  name="python-win-ad",
15
- version="0.6.2",
15
+ version="0.6.3",
16
16
  author="Zakir Durumeric",
17
17
  author_email="zakird@gmail.com",
18
18
  maintainer="Josh Carswell",
@@ -38,11 +38,10 @@ setup(
38
38
  "Operating System :: Microsoft :: Windows",
39
39
  "Topic :: System :: Systems Administration :: Authentication/Directory :: LDAP",
40
40
  "Programming Language :: Python :: 3",
41
- "Programming Language :: Python :: 3.6",
42
- "Programming Language :: Python :: 3.7",
43
41
  "Programming Language :: Python :: 3.8",
44
42
  "Programming Language :: Python :: 3.9",
45
43
  "Programming Language :: Python :: 3.10",
44
+ "Programming Language :: Python :: 3.11",
46
45
  ],
47
46
  install_requires=["setuptools", "pywin32"],
48
47
  )
@@ -0,0 +1,22 @@
1
+ from .pyadunittest import ADTestCase
2
+ from pyad.adbase import ADBase
3
+ import pyad
4
+
5
+ class TestADBase(ADTestCase):
6
+ def setUp(self):
7
+ # set all defaults back to their default
8
+ ADBase.default_ldap_server = None
9
+ ADBase.default_gc_server = None
10
+ ADBase.default_ldap_port = None
11
+ ADBase.default_gc_port = None
12
+
13
+ def test_detected_forest(self):
14
+ self.assertEqual(ADBase.default_domain, self.SANDBOX_DOMAIN)
15
+
16
+ def test_detected_domain(self):
17
+ self.assertEqual(ADBase.default_forest, self.SANDBOX_FOREST)
18
+
19
+ def test_set_defaults(self):
20
+ pyad.set_defaults(ldap_server = self.TEST_DC, ldap_port = 389)
21
+ self.assertEqual(ADBase.default_ldap_server, self.TEST_DC)
22
+ self.assertEqual(ADBase.default_ldap_port, 389)
@@ -0,0 +1,53 @@
1
+ from .pyadunittest import ADTestCase
2
+ import pyad
3
+
4
+ class TestADQuery(ADTestCase):
5
+ def setUp(self):
6
+ self.ad_query = pyad.ADQuery()
7
+
8
+ def test_dne_rowcount(self):
9
+ query = "cn = '%s'" % self.KNOWN_DNE_OBJECT
10
+ self.ad_query.execute_query(where_clause = query)
11
+ self.assertEqual(self.ad_query.row_count, 0)
12
+
13
+ def test_dne_single_result(self):
14
+ query = "cn = '%s'" % self.KNOWN_DNE_OBJECT
15
+ self.ad_query.execute_query(where_clause = query)
16
+ self.assertEquals(self.ad_query.get_single_result,{})
17
+
18
+ def test_dne_all_results(self):
19
+ query = "cn = '%s'" % self.KNOWN_DNE_OBJECT
20
+ self.ad_query.execute_query(where_clause = query)
21
+ self.assertEqual(self.ad_query.get_all_results(), [])
22
+
23
+ def test_single_rowcount(self):
24
+ query = "cn = '%s'" % self.KNOWN_EXISTS_USER
25
+ self.ad_query.execute_query(where_clause = query)
26
+ self.assertEqual(self.ad_query.get_row_count(), 1)
27
+
28
+ def test_single_single_result(self):
29
+ query = "cn = '%s'" % self.KNOWN_EXISTS_USER
30
+ self.ad_query.execute_query(attributes=("cn","distinguishedname"),where_clause = query)
31
+ self.assertEqual(self.ad_query.get_single_result()['cn'],self.KNOWN_EXISTS_USER)
32
+
33
+ def test_single_all_results(self):
34
+ query = "cn = '%s'" % self.KNOWN_EXISTS_USER
35
+ self.ad_query.execute_query(attributes=("cn","distinguishedname"),where_clause = query)
36
+ self.assertEqual(self.ad_query.get_all_results()[0]['cn'],self.KNOWN_EXISTS_USER)
37
+
38
+ def test_multiple_rowcount(self):
39
+ query = "cn = '%s' or cn = '%s'" % (self.KNOWN_EXISTS_USER, self.KNOWN_EXISTS_COMPUTER)
40
+ self.ad_query.execute_query(where_clause = query)
41
+ self.assertEqual(self.ad_query.row_count, 2)
42
+
43
+ def test_multiple_single_result(self):
44
+ query = "cn = '%s' or cn = '%s'" % (self.KNOWN_EXISTS_USER, self.KNOWN_EXISTS_COMPUTER)
45
+ self.ad_query.execute_query(where_clause = query)
46
+ self.assertIsInstance(self.ad_query.get_single_result,dict)
47
+
48
+ def test_multiple_all_results(self):
49
+ query = "cn = '%s' or cn = '%s'" % (self.KNOWN_EXISTS_USER, self.KNOWN_EXISTS_COMPUTER)
50
+ self.ad_query.execute_query(attributes=("cn","distinguishedname"),where_clause = query)
51
+ r = map(lambda x: x['cn'], self.ad_query.get_all_results())
52
+ k = [self.KNOWN_EXISTS_USER, self.KNOWN_EXISTS_COMPUTER]
53
+ self.assertEqual(r.sort(),k.sort())
File without changes
File without changes
File without changes