RoyBaird
Posts: 115
|
Posted: 07/24/2005, 9:42 PM |
|
Here is a tried and true VBscript that will return email address based on the partial name entered. I need to get this to populate a listbox in a pop-up page so the selected value can be passed back to the main page. I.E. User enters a partial name and all of the email address that match will be shown.
Option Explicit
Dim objCommand, objConnection, strBase, strFilter, strAttributes
Dim strQuery, objRecordset, strName, strCN
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://dc=domain,dc=com>" '***** this is where you put your domain ****
strFilter = "(&(objectCategory=person)(objectClass=user)(cn=*baird*))" '**** cn needs to be a user entered variable for the name to search for ****
strAttributes = "sAMAccountName,cn"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute
Do Until objRecordSet.EOF
strName = objRecordSet.Fields("sAMAccountName").Value
strCN = objRecordSet.Fields("cn").value
Document.Write "NT Name: " & strName & ", Common Name: " & strCN '**** this is the data I need in a list box *****
objRecordSet.MoveNext
Loop
objConnection.Close
_________________
Roy |
|
|
Nicole
Posts: 586
|
Posted: 07/25/2005, 6:16 AM |
|
Roy,
CCS Example Pack 2 solution includes good example of look up fields on a fly. You can check it at http://examples.codecharge.com/CCSExamplePack2/Retrievi...ieldsValues.php
_________________
Regards,
Nicole |
|
|
|