有办法让MS Access获取当前的Active Directory用户。MS Access可以通过使用ADO (ActiveX Data Objects) 和 ADOX (ActiveX Data Objects Extensions for Data Definition and Security) 来连接和操作Active Directory。以下是一个简单的示例,展示了如何使用ADO和ADOX来获取当前的Active Directory用户:
Dim objConnection As ADODB.Connection
Dim objCommand As ADODB.Command
Dim objRecordset As ADODB.Recordset
Set objConnection = New ADODB.Connection
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = New ADODB.Command
Set objCommand.ActiveConnection = objConnection
objCommand.CommandText = "SELECT ADsPath FROM 'LDAP://DC=example,DC=com' WHERE objectCategory='user'"
Set objRecordset = objCommand.Execute
If Not objRecordset.EOF Then
objRecordset.MoveFirst
Do Until objRecordset.EOF
Debug.Print objRecordset("ADsPath")
objRecordset.MoveNext
Loop
End If
objRecordset.Close
objConnection.Close
这个示例将会输出所有Active Directory用户的路径。可以根据需要修改查询语句以获取其他属性或筛选特定用户。
推荐的腾讯云相关产品和产品介绍链接地址:
领取专属 10元无门槛券
手把手带您无忧上云