473,386 Members | 1,754 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.

Querying Active Directory

I'm creating an Infopath form and I need to query Active Directory to obtain
some data. Here is the code I'm using (obtained from sample code from MSDN)

Private Shared domainADsPath As String = "LDAP://xxx.com"
Private Shared username As String = "gary"
Private Shared password As String = "password"
Private Shared schemaClassNameToSearch As String = "user"

Sub Lookup
Dim strUserName as String
Dim searcher As New DirectorySearcher()

searcher.SearchRoot = New DirectoryEntry(domainADsPath, username,
Password)
searcher.Filter = "(objectClass=" + schemaClassNameToSearch + ")"
searcher.SearchScope = SearchScope.Subtree
searcher.Sort = New SortOption("name", SortDirection.Ascending)
searcher.PropertiesToLoad.AddRange(New String() {"displayName", "name"})

Dim result As SearchResult
result = searcher.FindOne()

If Not (result Is Nothing) Then
Dim myResultPropColl As ResultPropertyCollection
Dim myResultPropValColl As ResultPropertyValueCollection
myResultPropColl = result.Properties
myResultPropValColl = myResultPropColl.Item("name")
strUserName = myResultPropValColl.Item(0).ToString()
thisXDocument.DOM.selectSingleNode("//my:Name").text = strUserName
Else
thisXDocument.DOM.selectSingleNode("//my:Name").text = "Not Found"
End If

What displays on the form is the object name
(ie. System.DirectoryServices.ResultPropertyValueCollec tion), not the value
of the property. All of the classes return an object and not a string. How do
I return the actual value of the property?

Thanks for the help!
--
Gary

Jul 14 '06 #1
0 970

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: James Allan | last post by:
Hello -- I'm trying to get SQL Server 2000 on a Windows 2000 Server to be able to query an Active Directory. We've got two domain servers one Win2000 and one Win2003. However, I'm having...
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...
0
by: Trey Mitchell | last post by:
I have built a single class in vb.Net to handle all active directory authentication needed in my web app. People can sign into the website with no problem. There is also a second form of...
0
by: Brian Mitchell | last post by:
Is there any way to return active directory objects from the object's guid? My basic problem is that I don't know the appropriate search filters. Does anyone know of any sites that list them? (like...
0
by: timmmahh | last post by:
Hi Does anyone have any tips/examples on how you can check if a windows user account has read access to a microsoft exchange public folder? My application can only access active directory, so...
3
by: Lucky | last post by:
Hi guys, after long long time. i'm back again with another problem. this time i think the problem is very very interesting and i really need you help on this. i'm trying to connect to the...
1
by: =?Utf-8?B?TWljaGFlbCBkZSBWZXJh?= | last post by:
To all, Is there a way to query all the objects in active directory within SQL Query analyzer? I really like to write my own sql statements before putting them into a sqlstr function within my...
3
by: Brian McCullough | last post by:
Hello, I am trying to query ADAM using the ActiveDirectoryMembershipProvider in my ASP.NET 2.0 application, but have been unsuccessful. I have followed the steps in these blog posts, but still...
4
by: =?Utf-8?B?U3VoYXMgVmVuZ2lsYXQ=?= | last post by:
Hello, I am facing an issue while querying Active directory using C# code with system.DirectoryServices namespace. Here is the path for my LDAP - "LDAP://CN=XY - C++/Unix and other,...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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.