473,669 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create an array

maxamis4
295 Recognized Expert Contributor
Hello,

My LDAP query is working. However I want to store the values in an array. Very simply put the examples online for arrays suck. Is there a very easy step by step method of creating a string array. Below is my code and what I tried to do:

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 String
  14.         'Dim myresults As String
  15.         Dim i As Integer
  16.  
  17.         i = 0
  18.  
  19.         UserID = txt_Name.Text
  20.         objSearch.PropertiesToLoad.Add("uid")
  21.         objSearch.PropertiesToLoad.Add("givenname")
  22.         objSearch.PropertiesToLoad.Add("cn")
  23.         objSearch.Filter = ("(samAccountName=*" & UserID & "*)")
  24.         oResults = objSearch.FindAll
  25.  
  26.         For Each oResult In oResults
  27.  
  28.             RetArray(i) = oResult.GetDirectoryEntry.Properties("cn").Value
  29.             RetArray.Sort(RetArray)
  30.  
  31.             lb_Names.Items.Add(RetArray)
  32.  
  33.  
  34.             i = i + 1
  35.         Next
  36.  
  37.     End Sub
  38.  
  39.  

any help is appreicated
Apr 15 '08 #1
0 767

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

Similar topics

7
8852
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
23
7397
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion. Each Directory object creates an array of Subdirectories each of which has an array of...
1
1336
geo039
by: geo039 | last post by:
Okay I have an application, which is to demonstrate the use of a created class. I have a previous and next button which cycles through the array. However I need the user to be able to create a new instance of the object then as they cycle through they see their new object. I am stuck on this part. I've tried a few things for my button create event but I have been getting an unhandled can't convert to 1 dimensional array among other things. Any...
10
3969
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item in the list A i want to associate an undetermined number of items. The complication for me is the fact that the items to associate in list A are undetermined.
3
4839
by: David K in San Jose | last post by:
I'm using managed (CLR) C++ in VS2005 to create a Windows app that contains a form named "MyForm". In the code for that form I'm trying to invoke some static functions by using an array of function pointers (delegates). I assume I need to use the array< T keyword to allocate an array of delegates, and then initialize the array by setting each array element to the pointers (handles) of the functions I'll be invoking. I've been trying to...
0
8465
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8383
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2797
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.