Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT * FROM OpenQuery(
- ADSI,
- 'SELECT displayName, title, department, employeeID, userAccountControl
- FROM ''LDAP://dc=testdomain''
- WHERE objectCategory = ''Person'' AND
- objectClass = ''user'' AND
- userAccountControl=512')
- Msg 7321, Level 16, State 2, Line 1
- An error occured while preparing the query "SELECT displayName, title, department, employeeID, userAccountControl
- FROM 'LDAP://dc=testdomain'
- WHERE objectCategory = 'Person' AND
- objectClass = 'user' AND
- userAccountControl=512" for execution against OLE DB provider "ADsDSOObject" for linked server "ADSI".
- SQL Server 11.0.5058
- Linked Server: ADSI
- Provider: OLE DB Provider for Microsoft Directory Services
- Product name: Active Directory Services 2.5
- Data source: adsdatasource
- Provider string: ADsDSOObject
- Be made using the login's current security context
- Ole DB Provider Options:
- Allow in process
- Failed to retreive data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)
- Additional information:
- An exception occured while executing a Transact-SQL statement or batch.
- (Microsoft.SqlServer.ConnectionInfo)
- Cannot obtain the required interface ("IID_IDBSchemaRowset") from OLE DB provider "ADsDSOObject"
- for linked server "ADSI". (Microsoft SQL Server, Error: 7301)
- 'References: Microsoft ActiveX Data Objects 2.8 Library
- Public Sub testADSI()
- On Error Resume Next
- Dim cn As ADODB.Connection
- Dim cmd As ADODB.Command
- Dim rs as ADODB.Recordset
- Dim MySql as String
- Dim n as Integer
- Set cn = New ADODB.Connection
- Set cmd = New ADODB.Command
- Set rs = New ADODB.Recordset
- cn.Provider = "ADsDSOObject"
- cn.Open "Active Directory Provider"
- Set cmd.ActiveConnection = cn
- cmd.Properties("Page Size")= 1000
- MySql = "SELECT displayName, title, department, employeedID, userAccountControl " & _
- "FROM 'LDAP://dc=testdomain' " _ &
- "WHERE objectCategory = 'Person' AND " & _
- "objectClass = 'user' AND " & _
- "userAccountControl=512"
- rs.Open MySql, cn, 1
- If rs.RecordCount > 0 Then
- MsgBox "Sucess! " & rs.RecordCount & " records found!"
- Else
- MsgBox "No records"
- End IF
- End Sub
Add Comment
Please, Sign In to add comment