Reputation: 47
Do you know if there are any issues opening an AD connection 3 times in a script? I'm building an HTA application for user terminations which is composed mainly by VBScript:
Sub Confirmation
-> connect to AD
-> check if user exists
-> end AD connection - objConnection.Close
-> ask user for confirmation to call Phase1 / Phase 2, else exit sub
Sub Phase1
-> connect to AD
-> perform actions
-> objConnection.Close
Sub Phase2
-> connect to AD
-> perform actions
-> objConnection.Close
Question is, does the connection remain active through Sub Phase1 and Sub Phase2 if I do not close it in Sub Confirmation?
Upvotes: 1
Views: 178
Reputation: 200193
That depends. It seems that you're waiting for user input before going from Confirmation
to Phase1
and/or Phase2
. That may take a long time, so it's possible the connection times out (default timeout is 15 seconds). In this scenario it's preferable to close the connection in Confirmation
and re-open it after the user made his choice.
OTOH, in situations where you don't have to wait for user input it's better to keep the connection open, because closing and re-opening it would just be unnecessary overhead.
Upvotes: 1