{"id":2864,"date":"2010-10-04T13:09:08","date_gmt":"2010-10-04T17:09:08","guid":{"rendered":"http:\/\/nuxx.net\/blog\/?p=2864"},"modified":"2010-10-12T23:05:28","modified_gmt":"2010-10-13T03:05:28","slug":"vbscript-function-to-check-active-directory-domain-access","status":"publish","type":"post","link":"https:\/\/nuxx.net\/blog\/2010\/10\/04\/vbscript-function-to-check-active-directory-domain-access\/","title":{"rendered":"VBScript Function to Check Active Directory Domain Access"},"content":{"rendered":"<p>The following <a href=\"http:\/\/en.wikipedia.org\/wiki\/VBScript\">VBScript<\/a> function can be used to check if a given username and password has access to the specified domain. It will return true or false depending on whether or not access was granted.<\/p>\n<p><tt>function&nbsp;fnCheckAccess(strDomain,&nbsp;strUserID,&nbsp;strUserPWD)<\/tt><br \/>\n<tt>&nbsp;<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;ADS_SECURE_AUTHENTICATION&nbsp;=&nbsp;&H01<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;ADS_CHASE_REFERRALS_ALWAYS&nbsp;=&nbsp;&H60<\/tt><br \/>\n<tt>&nbsp;<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;dim&nbsp;objDSO<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;dim&nbsp;objUser<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;dim&nbsp;strPath<\/tt><br \/>\n<tt>&nbsp;<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;strPath&nbsp;=&nbsp;\"LDAP:\/\/\"&nbsp;&&nbsp;strDomain<\/tt><br \/>\n<tt>&nbsp;<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;On&nbsp;Error&nbsp;Resume&nbsp;Next<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;objDSO&nbsp;=&nbsp;GetObject(\"LDAP:\")<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;objUser&nbsp;=&nbsp;objDSO.OpenDSObject(strPath,&nbsp;strUserID,&nbsp;strUserPWD,&nbsp;ADS_SECURE_AUTHENTICATION&nbsp;OR&nbsp;ADS_CHASE_REFERRALS_ALWAYS)<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Err.Number&nbsp;<>&nbsp;0&nbsp;then<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fnCheckAccess&nbsp;=&nbsp;False<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;else<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fnCheckAccess&nbsp;=&nbsp;True<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;if<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;Err.Clear<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;On&nbsp;Error&nbsp;Goto&nbsp;0<\/tt><br \/>\n<tt>&nbsp;<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;objDSO&nbsp;=&nbsp;Nothing<\/tt><br \/>\n<tt>&nbsp;&nbsp;&nbsp;&nbsp;set&nbsp;objUser&nbsp;=&nbsp;Nothing<\/tt><br \/>\n<tt>&nbsp;<\/tt><br \/>\n<tt>end&nbsp;function<\/tt><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following VBScript function can be used to check if a given username and password has access to the specified domain. It will return true&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/nuxx.net\/blog\/2010\/10\/04\/vbscript-function-to-check-active-directory-domain-access\/\">Continue reading<span class=\"screen-reader-text\">VBScript Function to Check Active Directory Domain Access<\/span><\/a><\/div>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,11],"tags":[],"class_list":["post-2864","post","type-post","status-publish","format-standard","hentry","category-computers","category-making-things","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/2864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/comments?post=2864"}],"version-history":[{"count":5,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/2864\/revisions"}],"predecessor-version":[{"id":2887,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/posts\/2864\/revisions\/2887"}],"wp:attachment":[{"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/media?parent=2864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/categories?post=2864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nuxx.net\/blog\/wp-json\/wp\/v2\/tags?post=2864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}