Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    [VB.NET] query su LDAP che restituisce il numero di telefono

    Salve a tutti,

    sono alle prime armi con VB.NET e dovrei popolare un dataset con una query fatta su LDAP che restituisce il nome e il numero di telefono di tutti gli utenti..
    ho creato la connessione e funziona ma non so come strutturare la query..

    Grazie mille

  2. #2

    OMG

    nessuno ha qualche idea??
    i campi su LDAP (Active Directory) sono: "sn" per il nome e "TelephoneNumber" per il telefono..
    per ora ho fatto così, ma non capisco il perché genera errore in *** dicendo che l'indice è andato oltre il range..



    Public Function GetPhoneUsers() As DataTable

    ' get list of active directory users

    ' setting up the lookup to AD

    Dim adEntry As New DirectoryEntry _
    ("LDAP://myserver.mydomain.com/DC=mydomain,DC=com")


    ' define which fields to retrieve from AD

    Dim adSearcher As New DirectorySearcher(adEntry)

    adSearcher.Filter = "(&(objectCategory=person)(objectClass=user))"

    adSearcher.PropertiesToLoad.Add("cn")

    adSearcher.PropertiesToLoad.Add("TelephoneNumber")

    ' define a datatable and add the results to it

    Dim adResults As SearchResultCollection

    Dim dt As New DataTable("AD_Users")

    dt.Columns.Add(New DataColumn("Name", GetType(System.String)))

    dt.Columns.Add(New DataColumn("TelephoneNumber", GetType(System.String)))

    Dim dr As DataRow

    adResults = adSearcher.FindAll

    For Each adResult As SearchResult In adResults

    ' add the results to the datatable

    dr = dt.NewRow()

    dr(0) = adResult.Properties("cn")(0).ToString()

    'dr(1) = adResult.Properties("TelephoneNumber")(0).ToString()

    dt.Rows.Add(dr)

    Next

    Return dt

    End Function




    Grazie

  3. #3

    Niente ragazzi??


Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.