473,569 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 schemaClassName ToSearch As String = "user"

Sub Lookup
Dim strUserName as String
Dim searcher As New DirectorySearch er()

searcher.Search Root = New DirectoryEntry( domainADsPath, username,
Password)
searcher.Filter = "(objectCla ss=" + schemaClassName ToSearch + ")"
searcher.Search Scope = SearchScope.Sub tree
searcher.Sort = New SortOption("nam e", SortDirection.A scending)
searcher.Proper tiesToLoad.AddR ange(New String() {"displayNam e", "name"})

Dim result As SearchResult
result = searcher.FindOn e()

If Not (result Is Nothing) Then
Dim myResultPropCol l As ResultPropertyC ollection
Dim myResultPropVal Coll As ResultPropertyV alueCollection
myResultPropCol l = result.Properti es
myResultPropVal Coll = myResultPropCol l.Item("name")
strUserName = myResultPropVal Coll.Item(0).To String()
thisXDocument.D OM.selectSingle Node("//my:Name").text = strUserName
Else
thisXDocument.D OM.selectSingle Node("//my:Name").text = "Not Found"
End If

What displays on the form is the object name
(ie. System.Director yServices.Resul tPropertyValueC ollection), 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 983

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

Similar topics

2
15182
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 problems: I've run the following query to setup the linked server: sp_addlinkedserver 'ADSI', 'Active Directory Service Interfaces', 'ADSDSOObject',...
1
4739
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 I have run into I am not sure how to fix, and really not sure what is causing it. Here's what is going on (test server - Windows 2003 Server): I...
0
1010
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 authentication that users can have to access the website. When they use the second form (uses db backend), I see if I know their AD username (stored in...
0
989
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 sn searches for surname) Thanks in advance!!
0
1342
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 if this level of security detail is not stored here (ie in the Exchange store instead) then I guess I'm stuck. I have read that public folder...
3
11282
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 Active Directory. for that i've added one linked server to connect to the active directory. and then query like this: adding linked server:
1
1346
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 vb.net code. Thanks for any help, Michael
3
2801
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 am not able to query ADAM. Every time I make a call to login, using the Membership.ValidateUser method, I keep getting a false value. I have tried...
4
1519
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, OU=Automatic,OU=DLs,DC=domain,DC=com"; I have replaced the / character with\/- but still is giving error while querying. Please help me to resolve this.
0
7697
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...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7968
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...
1
5512
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...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
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...

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.