msad 0.4.4__tar.gz → 0.5.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: msad
3
- Version: 0.4.4
3
+ Version: 0.5.0
4
4
  Summary: msad is a commandline for interacting with Active Directory
5
5
  Project-URL: Homepage, https://github.com/matteoredaelli/msad
6
6
  Project-URL: Issues, https://github.com/matteoredaelli/msad/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "msad"
3
- version = "0.4.4"
3
+ version = "0.5.0"
4
4
  authors = [
5
5
  { name="Matteo Redaelli", email="matteo.redaelli@gmail.com" },
6
6
  ]
@@ -157,62 +157,6 @@ def _pprint(ldapresult, out_format="json", sep="\t"):
157
157
  result = result + sep.join(new_values) + "\n"
158
158
  return result
159
159
 
160
- # def users(self, user):
161
- # """Find users inside AD. The
162
- # filter can be the cn or userPrincipalName or samaccoutnname or mail to be searched. Can contain *
163
- # """
164
- # result = msad.users(
165
- # self._conn, self._search_base, user, attributes=self._attributes
166
- # )
167
- # return self._pprint(result)
168
-
169
- # def is_disabled(self, user):
170
- # """Check if a user is disabled"""
171
- # return msad.user.is_disabled(self._conn, self._search_base, user)
172
-
173
- # def is_locked(self, user):
174
- # """Check if the user is locked"""
175
- # return msad.user.is_locked(self._conn, self._search_base, user)
176
-
177
- # def password_changed_in_days(self, user):
178
- # return msad.user.password_changed_in_days(self._conn, self._search_base, user)
179
-
180
- # def has_expired_password(self, user, max_age):
181
- # """Check is user has the expired password"""
182
- # return msad.has_expired_password(self._conn, self._search_base, user, max_age)
183
-
184
- # def has_never_expires_password(self, user):
185
- # """Check if a user has never expires password"""
186
- # return msad.has_never_expires_password(self._conn, self._search_base, user)
187
-
188
- # def check_user(self, user, max_age, groups=[]):
189
- # """Get some info about a user: is it locked? disabled? password expired?"""
190
- # return msad.check_user(self._conn, self._search_base, user, max_age, groups)
191
-
192
-
193
-
194
- # def user_groups(self, user_name=None, user_dn=None):
195
- # """Extract the list of groups of a user (using DN or sAMAccountName)"""
196
- # return msad.user.user_groups(
197
- # self._conn, self._search_base, self._limit, user_name, user_dn
198
- # )
199
-
200
-
201
- # def group_member(
202
- # self, group_name=None, group_dn=None, user_name=None, user_dn=None
203
- # ):
204
- # """Check if the user is a member of a group (using DN or sAMAccountName)"""
205
- # return msad.group_member(
206
- # conn=self._conn,
207
- # search_base=self._search_base,
208
- # group_name=group_name,
209
- # group_dn=group_dn,
210
- # user_name=user_name,
211
- # user_dn=user_dn,
212
- # )
213
-
214
-
215
-
216
160
  app = typer.Typer()
217
161
 
218
162
  @app.command()
@@ -69,7 +69,7 @@ def has_never_expires_password(conn, search_base: str, user: str):
69
69
  return True if len(result) == 1 else None
70
70
 
71
71
 
72
- def password_changed_in_days(conn, search_base: str, user: str, max_age: int, limit: int = 2000):
72
+ def password_changed_in_days(conn, search_base: str, user: str):
73
73
  # return search(conn, search_base, search_filter, attributes=attributes)
74
74
  search_filter = f"(samaccountname={user})"
75
75
  result = search(
@@ -83,12 +83,11 @@ def password_changed_in_days(conn, search_base: str, user: str, max_age: int, li
83
83
  now = datetime.datetime.now()
84
84
 
85
85
  if result == 0:
86
- return True
86
+ return "Unknown"
87
87
  else:
88
88
  delta = now - result.replace(tzinfo=None)
89
89
  days = delta.days
90
- return True if days > max_age else False
91
-
90
+ return days
92
91
 
93
92
  def check_user(conn, search_base:str, user:str, max_age:int, groups=[]):
94
93
  # result = {}
@@ -104,9 +103,6 @@ def check_user(conn, search_base:str, user:str, max_age:int, groups=[]):
104
103
  yield (
105
104
  {"password_changed_in_days": password_changed_in_days(conn, search_base, user)}
106
105
  )
107
- yield (
108
- {"has_expired_password": has_expired_password(conn, search_base, user, max_age)}
109
- )
110
106
  for group in groups:
111
107
  yield (
112
108
  {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes