I am trying to make a page which displays some user information returned from active directory. Here is my code so far:
Dim oConnection As OleDbConnection
Dim oCmd As OleDbCommand
Dim strADOQuery As String
Dim oleReader As OleDbDataReader
oConnection = New OleDbConnection()
oCmd = New OleDbCommand()
oConnection.ConnectionString = "Provider=ADsDSOObject;"
oConnection.Open()
oCmd.Connection = oConnection
strADOQuery = "select distinguishedName, cn, givenname, sn, mail, middleName, displayName, description, telephonenumber, physicalDeliveryOfficeName, employeeID from 'LDAP://dc=foo,dc=ac,dc=uk' WHERE objectCategory='Person' AND objectClass='user' AND sAMAccountName='" & Uname & "'"""
oCmd.CommandText = strADOQuery
oCmd.CommandTimeout = 600
oCmd.ExecuteReader()
While oleReader.Read
ADDN = r("distinguishedName")
ADCommonName = r("cn")
ADFirstName = r("givenname")
ADLastName = r("sn")
ADEmail = r("mail")
ADFirstandLast = r("displayName")
ADDescription = r("description")
ADTelephone = r("telephonenumber")
ADOffice = r("physicalDeliveryOfficeName")
ADStaffnum = r("employeeID")
End While
oConnection.Close()
oleReader.Close()
I'm finding it hard to see exactly what is wrong with the code. The error message presented is vague:
'ADsDSOObject' failed with no error message available, result code: DB_E_ERRORSINCOMMAND(0x80040E14).
Any assistance would be greatly appreciated
Thanks.