Exemplo n.º 1
0
 def test_encode_real_search_request(self):
     client = ldap.Client()
     filter = '(&(DnsDomain=FREEADI.ORG)(Host=magellan)(NtVer=\\06\\00\\00\\00))'
     req = client.create_search_request('', filter, ('NetLogon',),
                                       scope=ldap.SCOPE_BASE, msgid=4)
     fname = os.path.join(self.basedir(), 'lib/ad/protocol/test',
                          'searchrequest.bin')
     fin = file(fname)
     buf = fin.read()
     fin.close()
     assert req == buf
Exemplo n.º 2
0
 def _create_netlogon_query(self, domain, msgid):
     """Create a netlogon query for `domain'."""
     client = ldap.Client()
     hostname = misc.hostname()
     filter = '(&(DnsDomain=%s)(Host=%s)(NtVer=\\06\\00\\00\\00))' % \
              (domain, hostname)
     attrs = ('NetLogon', )
     query = client.create_search_request('',
                                          filter,
                                          attrs=attrs,
                                          scope=ldap.SCOPE_BASE,
                                          msgid=msgid)
     return query
Exemplo n.º 3
0
 def _parse_netlogon_reply(self, reply):
     """Parse a netlogon reply."""
     client = ldap.Client()
     messages = client.parse_search_result(reply)
     if not messages:
         return
     msgid, dn, attrs = messages[0]
     if not attrs.get('netlogon'):
         raise Error, 'No netlogon attribute received.'
     data = attrs['netlogon'][0]
     decoder = Decoder()
     decoder.start(data)
     result = decoder.parse()
     return result
Exemplo n.º 4
0
 def test_decode_real_search_reply(self):
     client = ldap.Client()
     fname = os.path.join(self.basedir(), 'lib/ad/protocol/test',
                          'searchresult.bin')
     fin = file(fname)
     buf = fin.read()
     fin.close()
     reply = client.parse_message_header(buf)
     assert reply == (4, 4)
     reply = client.parse_search_result(buf)
     assert len(reply) == 1
     msgid, dn, attrs = reply[0]
     assert msgid == 4
     assert dn == ''
     fname = os.path.join(self.basedir(), 'lib/ad/protocol/test',
                          'netlogon.bin')
     fin = file(fname)
     netlogon = fin.read()
     fin.close()
     assert attrs == { 'netlogon': [netlogon] }
Exemplo n.º 5
0
 def _parse_message_header(self, reply):
     """Parse an LDAP header and return the messageid and opcode."""
     client = ldap.Client()
     msgid, opcode = client.parse_message_header(reply)
     return msgid, opcode