Skip to content

Commit 3fb194a

Browse files
committed
adding computeraddr
1 parent 76f3a06 commit 3fb194a

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

msldap/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
__version__ = "0.3.10"
2+
__version__ = "0.3.11"
33
__banner__ = \
44
"""
55
# msldap %s

msldap/examples/msldapclient.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def __init__(self, url = None):
3333
self.connection = None
3434
self.adinfo = None
3535
self.ldapinfo = None
36+
self.domain_name = None
3637

3738
async def do_login(self, url = None):
3839
"""Performs connection and login"""
@@ -73,6 +74,7 @@ async def do_adinfo(self, show = True):
7374
try:
7475
if self.adinfo is None:
7576
self.adinfo = self.connection._ldapinfo
77+
self.domain_name = self.adinfo.distinguishedName.replace('DC','').replace('=','').replace(',','.')
7678
if show is True:
7779
print(self.adinfo)
7880
except:
@@ -100,6 +102,23 @@ async def do_asrep(self):
100102
except:
101103
traceback.print_exc()
102104

105+
async def do_computeraddr(self):
106+
"""Fetches all computer accounts"""
107+
try:
108+
await self.do_adinfo(False)
109+
#machine_filename = '%s_computers_%s.txt' % (self.domain_name, datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))
110+
111+
async for machine, err in self.connection.get_all_machines():
112+
if err is not None:
113+
raise err
114+
115+
dns = machine.dNSHostName
116+
if dns is None:
117+
dns = '%s.%s' % (machine.sAMAccountName[:-1], self.domain_name)
118+
119+
print(str(dns))
120+
except:
121+
traceback.print_exc()
103122

104123
async def do_dump(self):
105124
"""Fetches ALL user and machine accounts from the domain with a LOT of attributes"""

0 commit comments

Comments
 (0)