Fetching data from active directory

Hi all,
i need to fetch data from active directory for which i have a VB.net code but when i am using this code in the invoke code activity then it is not working.
i directly pasted the code in invoke code activity but it looks that i missed out something.
can anyone please let me know how to use this below code to fetch data from active directory:

Dim defaultNamingContext as string
dsEntry = new DirectoryEntry(“GC://rootDSE”)
defaultNamingContext = dsEntry.Properties(“rootDomainNamingContext”).Value.ToString()
dsEntry = new DirectoryEntry(“GC://” & defaultnamingcontext)
ds.SearchRoot = dsEntry
ds.Filter = “(” & SearchCriteria & “=” & SearchString & “)”
sr = ds.FindOne()
OutputValue = sr.Properties(FieldToBeExtracted)(0)
sr = Nothing
System.GC.Collect()

Input:

  1. [AD ID]
  2. Search criteria
  3. Field

Output

  1. Value
  2. Exists (flag)

@Lahiru.Fernando ,
@supermanPunch
@codemonkee
can any of you please help in this?..its pretty important

Regards
Som

@som17 Are you sure the Code works? When you place this in Invoke Code Activity, Do you get an Error or there is no output generated from the Invoke Code? Can you provide the Workflow for the same where you have used this code in the Invoke Code Activity?