Skip to content
Open
Show file tree
Hide file tree
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
17 changes: 17 additions & 0 deletions msldap/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,23 @@ async def get_all_schemaentry(self, attrs:List[str] = MSADSCHEMAENTRY_ATTRS):

logger.debug('Finished polling for entries!')

async def get_dn(self, sAMAccountName: str):
"""
Fetches the distinguished name for a samAccountName.

:param sAMAccountName: The username of the machine (eg. COMP123$).
:type sAMAccountName: str
:return: DN if found, else None; and an error if any.
:rtype: Tuple[Optional[str], Optional[Exception]]
"""
ldap_filter = r'(sAMAccountName=%s)' % str(sAMAccountName)
async for entry, err in self.pagedsearch(ldap_filter, ['distinguishedName']):
if err is not None:
return None, err

return entry['attributes']['distinguishedName'], None
return None, Exception('Search returned no results!')

async def get_laps(self, sAMAccountName:str):
"""
Fetches the LAPS password for a machine. This functionality is only available to specific high-privileged users.
Expand Down
1 change: 1 addition & 0 deletions msldap/protocol/typeconversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ def multi_sd(x, encode=False):
"msDS-ManagedPasswordInterval" : single_int,
"msDS-SupportedEncryptionTypes" : single_int,
"msDS-GroupMSAMembership" : single_sd,
"pwdLastSet" : single_int,
}

def encode_attributes(x):
Expand Down