473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

LDAP Query in VB.NET

maxamis4
295 Expert 100+
Below is a code I am trying to write to retrieve information from LDAP using VB.NET. I am very versed in VB but .NET seems so foreign. If anyone can provide links and resources on how to use VB.NET with LDAP it would be greatly appreicated.


Expand|Select|Wrap|Line Numbers
  1.         Private Sub btn_Search_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Search.Click
  2.  
  3.         Dim UserID As String
  4.         Dim RootDSE As New DirectoryServices.DirectoryEntry("LDAP://RootDSE")
  5.         Dim DomainDN As String = RootDSE.Properties("DefaultNamingContext").Value
  6.         Dim ADEntry As New DirectoryServices.DirectoryEntry("LDAP://" & DomainDN)
  7.  
  8.  
  9.         Dim objSearch As New System.DirectoryServices.DirectorySearcher(ADEntry)
  10.         'Dim ADSearchResult As System.DirectoryServices.SearchResult
  11.         Dim oResults As DirectoryServices.SearchResultCollection
  12.         Dim oResult As DirectoryServices.SearchResult
  13.         Dim RetArray As New Hashtable
  14.         Dim myresults As String
  15.  
  16.         UserID = "Gomez"
  17.         objSearch.PropertiesToLoad.Add("uid")
  18.         objSearch.PropertiesToLoad.Add("givenname")
  19.         objSearch.PropertiesToLoad.Add("cn")
  20.         objSearch.Filter = ("(samAccountName=*" & UserID & "*)")
  21.         oResults = objSearch.FindAll
  22.  
  23.         For Each oResult In oResults
  24.  
  25.             myresults = oResult.GetDirectoryEntry.Properties("givenname").Value
  26.  
  27.             MsgBox(myresults)
  28.  
  29.         Next
  30.  
  31.     End Sub
  32.  
Apr 15 '08 #1
1 2950
maxamis4
295 Expert 100+
Its working now. Please ignore.
Apr 15 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: jeremy | last post by:
Hello. I have an asp.net application that resides on a non-DC / BDC Sharepoint Server (although it is logged into the domain). The application will perform lookups based on the current user...
4
by: m96 | last post by:
hi, i'm trying to make a query to a ldap server (version v2 or v3 doen't matter) with c#. the query works just fine but the problem is that i can't read the custom attributes/fields, since .net...
3
by: Jay | last post by:
I have a simple LDAP query (grabs all users from a particular AD group and populates a checkboxlist) that works perfectly fine on the development machine logged on locally as any user. When I...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
3
by: Chad Beckner | last post by:
I am starting to translate some code from ASP to ASP.NET (VB). I was able to query ADS to get a users groups that they belong to, and also query a group and get a list of users. However, I can't...
5
by: Bryan | last post by:
Hello, I have a asp.net app working with directory services on my Windows XP development machine. However when I moved the application over to our production server (Win 2000 Server) it no longer...
4
by: h2so4 | last post by:
I want to write a program that will query an ldap directory. can I use adsi or ado to do that, If yes how ? tx -- h2so4
0
by: Gerry Sinkiewicz | last post by:
Looking for a bit of software that will accept an LDAP query via port 389 and convert it to an SQL query and return the results to the originating LDAP client. Basically a dialect converter LDAP...
3
by: RJN | last post by:
Hi I've written a code that queries Windows LDAP server and works fine, but the same doesn't work when querying Solaris LDAP server. DirectoryEntry de = new...
3
by: eleland | last post by:
I am trying to bind to an LDAP server using php without success. I have a linux server running php compiled with open ldap. I am using the following code taken right from php.net: echo "<h3>LDAP...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.