• LS函数:在AD中,查询指定用户条目


    01 Function SearchAD(userName As String) As String  
    02    Dim objConnection As Variant  
    03    Dim objCommand As Variant  
    04    Dim objRecordSet As Variant  
    05    Const ADS_SCOPE_SUBTREE = 2
    06 
    07    On Error Goto errHandler    
    08    Set objConnection = CreateObject("ADODB.Connection")
    09    Set objCommand = CreateObject("ADODB.Command")
    10    objConnection.Provider = "ADsDSOObject"
    11    objConnection.Open "Active Directory Provider"
    12    Set objCommand.ActiveConnection = objConnection
    13    objCommand.Properties("Page Size") = 1000
    14    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
    15    ' Note: 使用ADS中属性查询
    16    ' 查询语句,相关语句可查询MSDN中相关对象
    17    objCommand.CommandText = "SELECT * FROM 'http://www.cnblogs.com/hannover/admin/ldap://10.1.1.8/' WHERE cn='"+userName+"' "  
    18 
    19    Set objRecordSet = objCommand.Execute      
    20    If ( objRecordSet.RecordCount = 0 ) Then
    21        SearchLDAP="0"
    22    Else
    23        SearchLDAP="1"
    24    End If
    25    objRecordSet.close
    26 
    27    Exit Function
    28errHandler:
    29    Msgbox "Error is : " & Error$ & " at line number : " & Cstr(Erl) & " in SearchAD() " & " while processing user : " & userName
    30    Exit Function
    31End Function
  • 相关阅读:
    Codeforces Round #226 (Div. 2)
    内存管理
    C/C++ 函数
    Codeforces Round #225 (Div. 2)
    常用链表操作总结
    Codeforces Round #224 (Div. 2)
    Codeforces Round #223 (Div. 2)
    Codeforces Round #222 (Div. 2)
    -树-专题
    Codeforces Round #221 (Div. 2)
  • 原文地址:https://www.cnblogs.com/hannover/p/2180357.html
Copyright © 2020-2023  润新知