diff --git a/examples/GetNPUsers.py b/examples/GetNPUsers.py index 06d65ea53..9f037a6e1 100755 --- a/examples/GetNPUsers.py +++ b/examples/GetNPUsers.py @@ -257,6 +257,8 @@ def run(self): logging.info('Getting TGT for %s' % self.__username) entry = self.getTGT(self.__username) self.outputTGT(entry, fd) + if fd is not None: + fd.close() return # Connect to LDAP @@ -280,7 +282,9 @@ def run(self): # Cannot authenticate, we will try to get this users' TGT (hoping it has PreAuth disabled) logging.info('Cannot authenticate %s, getting its TGT' % self.__username) entry = self.getTGT(self.__username) - self.outputTGT(entry, fd) + self.outputTGT(entry, fd) + if fd is not None: + fd.close() return