hello friends I am using actice directory as my data source through LDAP to get the usernam/password, and thn after authantication i use LDAP to get the user information (username, name, phone, email, location etc from active directory user profiles)
As u can see in the code i am using the loop to write the information on the page using
Response. write
I wan't to use some other data control to make the output more redable, like Repeater.
Sub getdetails()
Dim objCommand, objConnection, strBase, strFilter, strAttributes
'Declare the variables as string
Dim strQuery, objRecordset, strName, strCN, strCompany, strOfficeLocation, strDept, strJobtitle, strStreetAddress, strCounty, strPostalcode, strPhone, strMail
objCommand = CreateObject(
"ADODB.Command")
objConnection = CreateObject(
"ADODB.Connection")
objConnection.Provider =
"ADsDSOObject"
objConnection.Open(
"Active Directory Provider")
objCommand.ActiveConnection = objConnection
'Define the Search Base, Filter and Attributes
strBase =
"<LDAP://dc=ESPRIT,dc=local>"
strFilter =
"(&(objectCategory=person)(objectClass=user)(sAMAccountName=" + Me.lbl_welcome.Text + "))"
'database field name are same as in AD
strAttributes =
"sAMAccountName,cn,company,l,department,title,streetAddress,st,postalCode,telephonenumber,mail"
'Subtree is the default base
strQuery = strBase &
";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
'objCommand.Properties("Page Size") = 100
'objCommand.Properties("Timeout") = 30
' objectCommand_Properties(cache Results) if set to False gives some error so keep it True always
objCommand.Properties(
"Cache Results") = True
objRecordset = objCommand.Execute
'Pick the values of the fields in string variables
Do Until objRecordset.EOF
'Search the whole database Record till EOF and put the field value in the string variable and write it to the document(page)
strName = objRecordset.Fields(
"sAMAccountName").Value
strCN = objRecordset.Fields(
"cn").value
strCompany = objRecordset.Fields(
"company").value
strOfficeLocation = objRecordset.Fields(
"l").value
strDept = objRecordset.Fields(
"department").value
strJobtitle = objRecordset.Fields(
"title").value
strStreetAddress = objRecordset.Fields(
"streetAddress").value
strCounty = objRecordset.Fields(
"st").value
strPostalcode = objRecordset.Fields(
"postalCode").value
strPhone = objRecordset.Fields(
"telephonenumber").value
strMail = objRecordset.Fields(
"mail").value
Response.Write(
"User Name: " & strName & " Common Name: " & strCN & " Company Name: " & strCompany & " Office/Branch " & strOfficeLocation & " Department Name: " & strDept & " Job Title: " & strJobtitle & " Full Address: " & strStreetAddress & " County: " & strCounty & " Postal Code: " & strPostalcode & " Phone: " & strPhone & " Email: " & strMail)
objRecordset.MoveNext()
Loop
objConnection.Close()
'Connection Closed
End Sub
I am using object recordset for this. can anybdy suggest me how i can use some other datacontrol with this coding.
Thanks
Enter your message below
Sign in or Join us (it's free).