I'm attempting to read a couple of Active Directory field values (fields are distinguishedName & Description) using the Microsoft.Visual Basic Class. However, I had two sets of code I merged (one set of code had Option Strict On and the other one I forgot to turn on) caused some errors to come up.
I received the error "Option Strict On prohibits operands of Type Object for Operator '&'" on this line of code: --> objRecordSet.Fields("disti
) <-- and then I received this error, "AccountDisabled is not a member of 'ADODB.RecordSet'." on this line of code: --> If objAccount.AccountDisabled
Please see code snippet below. I would appreciate any assistance on which Classes/Methods or Properites to use NOW that I've implemented Option Strict On for all the code.
'If there is still an available Host record and the Host is disabled in AD, lets disable it on the database if not already.
ElseIf IsDBNull(objRecordSet.Fields("distinguishedName").Value) = False And IsDBNull(objRecordSet.Fields("description").Value) = False Then
While Not objRecordSet.EOF
Dim objAccount As ADODB.Recordset = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName").Value)
If objAccount.AccountDisabled Then
' Connect to DB and set the Status field to "Disabled" and
' the Flag(soon to be DaysOffline) field to 29 days.
Dim sqlCon As New SqlClient.SqlConnection
Dim sqlCom As New SqlClient.SqlCommand
sqlCon.ConnectionString = My.Settings.ConnectionString