• LDAP获取AD信息


    Public Sub getMyGroup()
    On Error Resume Next
    intRow = 18
    intCol = 4
    On Error Resume Next
    Set objADSysInfo = CreateObject("ADSystemInfo")
    strUser = objADSysInfo.UserName
    Set userinfo = GetObject("LDAP://" & strUser)
    
    'Debug.Print "buildingname", userinfo.buildingname
    'Debug.Print "c", userinfo.c
    'Debug.Print "cn", userinfo.cn
    'Debug.Print "co", userinfo.co
    'Debug.Print "comment", userinfo.Comment
    'Debug.Print "commonname", userinfo.commonname
    'Debug.Print "company", userinfo.Company
    'Debug.Print "description", userinfo.Description
    'Debug.Print "distinguishedname", userinfo.distinguishedname
    'Debug.Print "dn", userinfo.dn
    'Debug.Print "department", userinfo.Department
    'Debug.Print "displayname", userinfo.DisplayName
    'Debug.Print "facsimiletelephonenumber", userinfo.facsimiletelephonenumber
    'Debug.Print "fax", userinfo.fax
    'Debug.Print "friendlycountryname", userinfo.friendlycountryname
    'Debug.Print "givenname", userinfo.givenname
    'Debug.Print "homephone", userinfo.homephone
    'Debug.Print "homepostaladdress", userinfo.homepostaladdress
    'Debug.Print "info", userinfo.info
    'Debug.Print "initials", userinfo.initials
    'Debug.Print "ipphone", userinfo.ipphone
    'Debug.Print "l", userinfo.l
    'Debug.Print "mail", userinfo.mail
    'Debug.Print "mailnickname", userinfo.mailnickname
    'Debug.Print "rfc822mailbox", userinfo.rfc822mailbox
    'Debug.Print "mobile", userinfo.Mobile
    'Debug.Print "mobiletelephonenumber", userinfo.mobiletelephonenumber
    'Debug.Print "name", userinfo.Name
    'Debug.Print "othertelephone", userinfo.othertelephone
    'Debug.Print "ou", userinfo.ou
    'Debug.Print "pager", userinfo.Pager
    'Debug.Print "pagertelephonenumber", userinfo.pagertelephonenumber
    'Debug.Print "physicaldeliveryofficename", userinfo.physicaldeliveryofficename
    'Debug.Print "postaladdress", userinfo.postaladdress
    'Debug.Print "postalcode", userinfo.postalcode
    'Debug.Print "postofficebox", userinfo.postofficebox
    'Debug.Print "samaccountname", userinfo.samaccountname
    'Debug.Print "serialnumber", userinfo.serialnumber
    'Debug.Print "sn", userinfo.sn
    'Debug.Print "surname", userinfo.surname
    'Debug.Print "st", userinfo.st
    'Debug.Print "stateorprovincename", userinfo.stateorprovincename
    'Debug.Print "street", userinfo.Street
    'Debug.Print "streetaddress", userinfo.streetaddress
    'Debug.Print "telephonenumber", userinfo.telephonenumber
    'Debug.Print "title", userinfo.Title
    'Debug.Print "uid", userinfo.uid
    'Debug.Print "url", userinfo.URL
    'Debug.Print "userprincipalname", userinfo.userprincipalname
    'Debug.Print "wwwhomepage", userinfo.wwwhomepage
    'Debug.Print "Address", userinfo.Address
    'Debug.Print "Address, Home", userinfo.Address, Home
    'Debug.Print "Building", userinfo.Building
    'Debug.Print "City", userinfo.City
    'Debug.Print "Comment", userinfo.Comment
    'Debug.Print "Company", userinfo.Company
    'Debug.Print "Country", userinfo.Country
    'Debug.Print "Department", userinfo.Department
    'Debug.Print "Description", userinfo.Description
    'Debug.Print "Distinguished Name", userinfo.Distinguished; Name
    'Debug.Print "Email Address", userinfo.Email; Address
    'Debug.Print "Facsimile", userinfo.Facsimile
    'Debug.Print "Information", userinfo.Information
    'Debug.Print "Middle Initial", userinfo.Middle; Initial
    'Debug.Print "Name, First", userinfo.Name, First
    'Debug.Print "Name, Full", userinfo.Name, Full
    'Debug.Print "Name, Last", userinfo.Name, Last
    'Debug.Print "Office", userinfo.Office
    'Debug.Print "Organizational Unit", userinfo.Organizational; Unit
    'Debug.Print "Pager", userinfo.Pager
    'Debug.Print "Serial Number", userinfo.Serial; Number
    'Debug.Print "State", userinfo.State
    'Debug.Print "Street", userinfo.Street
    'Debug.Print "Telephone", userinfo.Telephone
    'Debug.Print "Telephone, Home", userinfo.Telephone, Home
    'Debug.Print "Telephone, IP", userinfo.Telephone, IP
    'Debug.Print "Telephone, Mobile", userinfo.Telephone, Mobile
    'Debug.Print "Telephone, Other", userinfo.Telephone, Other
    'Debug.Print "Title", userinfo.Title
    'Debug.Print "User ID", userinfo.User; ID
    'Debug.Print "Web Page, Main", userinfo.Web; Page, Main
    'Debug.Print "Web Page, Other", userinfo.Web; Page, Other
    'Debug.Print "Zip Code", userinfo.Zip; Code
    
    
    '通过这个获取ldap信息
    'Debug.Print strUser
    
    Dim s As String
    s = "OUxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxDC=if,DC=atcsg,DC=net"
    Set inf = GetObject("LDAP://" & s)
    Dim r, c As Integer
    r = 2
    c = 1
    For Each ss In inf
      
       Cells(r, c) = ss.department
       Cells(r, c + 1) = ss.Title
       Cells(r, c + 2) = ss.extensionAttribute2
       Cells(r, c + 3) = ss.FirstName
       Cells(r, c + 4) = ss.FullName
       Cells(r, c + 5) = ss.LastName
       Cells(r, c + 6) = ss.mail
       Cells(r, c + 7) = ss.PasswordLastChanged
       Cells(r, c + 8) = ss.sAMAccountname
       Cells(r, c + 9) = ss.WhenChanged
       Cells(r, c + 10) = ss.WhenCreated
       Cells(r, c + 11) = ss.company
       Cells(r, c + 12) = ss.Description
       Cells(r, c + 13) = ss.mobile
       Cells(r, c + 14) = ss.telephonenumber
       r = r + 1
       
    Next
    'Set objUser = GetObject("LDAP://" & strUser)
    
    
    
    '获取当前用户所在用户组
    'For Each strGroup In objUser.memberOf
    '    Set objGroup = GetObject("LDAP://" & strGroup)
    '    Cells(intRow, intCol).Value = objGroup.CN
    '    intRow = intRow + 1
    'Next
    
    End Sub
    

      

  • 相关阅读:
    linux固定ip设置
    经典shell面试题
    shell学习笔记
    从tcp到netty(二)
    Mysql复习
    从tcp到netty(一)
    浏览器展示图片(非下载)- java
    异常总结
    反射获取属性值并设置属性值
    TreeMap解析
  • 原文地址:https://www.cnblogs.com/pythonClub/p/15907843.html
Copyright © 2020-2023  润新知