LoginSignup
2
8

More than 5 years have passed since last update.

excel vbaで ldap検索

Posted at

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

search_ldap.vb
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 に触れたくなるんですよね

2
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
8