首页 > 其他分享 >vba ad域服务器信息怎么获取,获取AD域用户登入信息

vba ad域服务器信息怎么获取,获取AD域用户登入信息

时间:2022-11-28 21:01:37浏览次数:46  
标签:objRecordSet vba Set ad currCell 获取 objCommand objConnection

Private Sub CommandButton1_Click()
    On Error Resume Next

    Const ADS_SCOPE_SUBTREE = 2
    
    Set objConnection = CreateObject('ADODB.Connection')
    Set objCommand = CreateObject('ADODB.Command')
    objConnection.Provider = 'ADsDSOObject'
    objConnection.Open 'Active Directory Provider'
    Set objCommand.ActiveConnection = objConnection
    
    objCommand.Properties('Page Size') = 1000
    objCommand.Properties('Searchscope') = ADS_SCOPE_SUBTREE
    
    objCommand.CommandText = _
        'SELECT Name FROM 'LDAP://dc=XXX,dc=com' WHERE objectCategory='user'' 'search all users from the domn XXX
    Set objRecordSet = objCommand.Execute
    objRecordSet.MoveFirst
    
    Dim currCell As Range
    Set currCell = Range('A1')
    
    Do Until objRecordSet.EOF
        currCell.Value = objRecordSet.fields('Name').Value
        Set currCell = currCell.Offset(1, 0)
        objRecordSet.MoveNext
    Loop
End Sub

 https://blog.csdn.net/weixin_29129919/article/details/119410825

标签:objRecordSet,vba,Set,ad,currCell,获取,objCommand,objConnection
From: https://www.cnblogs.com/Insist-Y/p/16933592.html

相关文章