end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

excel vbaで ldap検索

多分、次のような感じ。
ただ、手元に試せるldapがないので、動かしていません。

Private Sub SearchLDAP(ByVal Row As Integer, ByVal Column As Integer)
    
    Dim ret As String, ret2 As String
    Dim UID As String
    Dim strLDAP As String
    Dim oLDAP As Object
    
    On Error Resume Next
    While Cells(Row, StartCol).Value <> ""
      If Cells(Row, Column + NameOffset).Value = "" Then
        UID = Cells(Row, Column).Value
        If UID <> "" Then
            strLDAP = "LDAP://ldap.xxx.yyy.co.jp/uid=" & _
                      UID & ",ou=people,o=xxx-group"
            Set oLDAP = GetObject(strLDAP)
            'set oLDAP.ld_sizeLimit = 100
    
            Cells(Row, Column + 1).Value = oLDAP.GET("mail")
            Cells(Row, Column + 2).Value = oLDAP.GET("cn")
            Cells(Row, Column + 3).Value = oLDAP.GET("o") &" "& oLDAP.GET("ou")
        End If
      End If
        Row = Row + 1
    Wend

End Sub

たまに、visual basic に触れたくなるんですよね