Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Search info #644

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion cme/modules/user_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def on_login(self, context, connection):
try:
sc = ldap.SimplePagedResultsControl()
connection.ldapConnection.search(searchFilter=self.search_filter,
attributes=['sAMAccountName', 'description'],
attributes=['sAMAccountName', 'description', 'info'],
sizeLimit=0, searchControls=[sc],
perRecordCallback=self.process_record)

Expand Down Expand Up @@ -128,6 +128,7 @@ def process_record(self, item):

sAMAccountName = ''
description = ''
info = ''

try:

Expand All @@ -138,6 +139,8 @@ def process_record(self, item):

elif str(attribute['type']) == 'description':
description = attribute['vals'][0].asOctets().decode('utf-8')
elif str(attribute['type']) == 'info':
description = attribute['vals'][0].asOctets().decode('utf-8')

except Exception as e:

Expand All @@ -153,6 +156,16 @@ def process_record(self, item):
self.context.log.highlight('User: {} - Description: {}'.format(sAMAccountName, description))

self.account_names.add(sAMAccountName)
if info and sAMAccountName not in self.account_names:

self.desc_count += 1
self.append_to_log(sAMAccountName, info)

if self.highlight(info):
self.context.log.highlight('User: {} - Description: {}'.format(sAMAccountName, info))

self.account_names.add(sAMAccountName)


def highlight(self, description):
'''
Expand All @@ -173,3 +186,4 @@ def highlight(self, description):
return True

return False