diff --git a/msldap/client.py b/msldap/client.py index edd39c7..6646253 100644 --- a/msldap/client.py +++ b/msldap/client.py @@ -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. diff --git a/msldap/protocol/typeconversion.py b/msldap/protocol/typeconversion.py index 5423e4b..8c4c793 100644 --- a/msldap/protocol/typeconversion.py +++ b/msldap/protocol/typeconversion.py @@ -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):