VbsEdit, the award-winning VBScript editor that dramatically reduces the time you spend writing .VBS scripts

Sample scripts


Scripting Techniques
   Searching Active Directory
       Search for a SAM Account Name , LDAP

' Search for a SAM Account Name


On Error Resume Next

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = ("ADsDSOObject")
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT samAccountName FROM " & _
    "'LDAP://dc=fabrikam,dc=com' " & _
        "WHERE samAccountName = 'kenmyer'"
objCommand.Properties("SearchScope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute

If objRecordSet.RecordCount = 0 Then
    Wscript.Echo "The samAccount name is not being used."
Else
    Wscript.Echo "The samAccount name is being used."
End If



VbsEdit includes all these samples!




Download Now!

Version 5.4.1 - This package includes VbsEdit 32-bit, VbsEdit 64-bit, HtaEdit 32-bit and HtaEdit 64-bit.
The evaluation version never expires.



Home   Buy Now   HtaEdit   Support   Video   What's new ?  

Copyright (C) 2001-2012 Adersoft