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 stringDim strQuery, objRecordset, strName, strCN, strCompany, strOfficeLocation, strDept, strJobtitle, strStreetAddress, strCounty, strPostalcode, strPhone, strMailobjCommand = CreateObject(
"ADODB.Command")objConnection = CreateObject(
"ADODB.Connection")objConnection.Provider =
"ADsDSOObject"objConnection.Open(
"Active Directory Provider")objCommand.ActiveConnection = objConnection
'Define the Search Base, Filter and AttributesstrBase =
"<LDAP://dc=ESPRIT,dc=local>"strFilter =
"(&(objectCategory=person)(objectClass=user)(sAMAccountName=" +Me.lbl_welcome.Text +"))"'database field name are same as in ADstrAttributes =
"sAMAccountName,cn,company,l,department,title,streetAddress,st,postalCode,telephonenumber,mail"'Subtree is the default basestrQuery = 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 alwaysobjCommand.Properties(
"Cache Results") =TrueobjRecordset = objCommand.Execute
'Pick the values of the fields in string variablesDoUntil 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").ValuestrCN = objRecordset.Fields(
"cn").valuestrCompany = objRecordset.Fields(
"company").valuestrOfficeLocation = objRecordset.Fields(
"l").valuestrDept = objRecordset.Fields(
"department").valuestrJobtitle = objRecordset.Fields(
"title").valuestrStreetAddress = objRecordset.Fields(
"streetAddress").valuestrCounty = objRecordset.Fields(
"st").valuestrPostalcode = objRecordset.Fields(
"postalCode").valuestrPhone = objRecordset.Fields(
"telephonenumber").valuestrMail = objRecordset.Fields(
"mail").valueResponse.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()
LoopobjConnection.Close()
'Connection ClosedEndSub
I am using object recordset for this. can anybdy suggest me how i can use some other datacontrol with this coding.
Thanks
You mentioned you wanted to use a repeater which is an ASP.NET control, but your code looks like Classic ASP. What are you using ASP.NET or Classic ASP?
0 comments:
Post a Comment