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

Home Posts Topics Members FAQ

Query Active Directory for User ID

11 New Member
Hi,
I am new to active directory and am trying to query it for the user name and ID of members of a group to populate a drop down list in the form: firstname lastname (userID)
When I run the page which calls this function through visual studio it works fine and the drop down list is populated. However when I run the page over the intranet I get this error.

Unknown error (0x8000500c)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Unknown error (0x8000500c)
Exception Details: System.Runtime. InteropServices .COMException:

Source Error:

Line 152: userProps = gpMemberEntry.P roperties

Line 154: obVal = userProps("Give nName").Value & " " & userProps("sn") .Value & " (" & userProps("sAMA ccountName").Va lue & ")"

with this code:
Dim _path As String = "LDAP://WI.FCIB.COM/DC=WI, DC=FCIB, DC=COM"
Dim groupMembers As New StringCollectio n


' Try
Dim ent As New DirectoryEntry( _path)
Dim srch As New DirectorySearch er("(" & strGroup & ")")
Dim coll As SearchResultCol lection

'Get the results
coll = srch.FindAll()

Dim rs As SearchResult

'Get the information for each member found
For Each rs In coll

Dim resultPropColl As ResultPropertyC ollection
Dim memberColl As Object

resultPropColl = rs.Properties

For Each memberColl In resultPropColl( "member")

Dim gpMemberEntry As New DirectoryEntry( "LDAP://WI.FCIB.COM/" & memberColl.ToSt ring)
Dim userProps As PropertyCollect ion
Dim obVal As Object

userProps = gpMemberEntry.P roperties

obVal = userProps("Give nName").Value & " " & userProps("sn") .Value & " (" & userProps("sAMA ccountName").Va lue & ")"

If Not obVal Is Nothing Then
groupMembers.Ad d(obVal.ToStrin g)
End If

Next

Next

Return groupMembers

'Catch ex As Exception
' Return Nothing
'End Try

For some quick debugging I tried:
Dim _path As String = "LDAP://WI.FCIB.COM/DC=WI, DC=FCIB, DC=COM"
Dim groupMembers As New StringCollectio n


' Try
Dim ent As New DirectoryEntry( _path)
Dim srch As New DirectorySearch er("(" & strGroup & ")")
Dim coll As SearchResultCol lection

'Get the results
coll = srch.FindAll()

Dim rs As SearchResult

'Get the information for each member found
For Each rs In coll

Dim resultPropColl As ResultPropertyC ollection
Dim memberColl As Object

resultPropColl = rs.Properties

For Each memberColl In resultPropColl( "member")

Dim gpMemberEntry As New DirectoryEntry( "LDAP://WI.FCIB.COM/" & memberColl.ToSt ring)
Dim userProps As PropertyCollect ion
Dim obVal As Object

userProps = gpMemberEntry.P roperties

My.Response.Wri te("< br/>" & userProps("Give nName").Value)
My.Response.Wri te(" " & userProps("sn") .Value)
My.Response.Wri te(" " & userProps("sAMA ccountName").Va lue)
'obVal = userProps("Give nName").Value & " " & userProps("sn") .Value & " (" & userProps("SAMA ccountName").Va lue & ")"

'If Not obVal Is Nothing Then
' groupMembers.Ad d(obVal.ToStrin g)
'End If

Next

Next

Return groupMembers

'Catch ex As Exception
' Return Nothing
'End Try

Which gave me the same error except it was for the line:
My.Response.Wri te(" " & userProps("sAMA ccountName").Va lue)

Does this then mean that I can't load this attribute? And if so, how can I get around it because I must get the userIDs from AD

Thanks for the help.
Jun 29 '07 #1
0 4151

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

Similar topics

4
3856
by: ASGMikeG | last post by:
Hi, How do I find the user object for the current user in Active Directory i.e. the user running my program ? Regards Michael
0
1120
by: Andrew Connell | last post by:
I have a case where I need to be able to query Active Directory to look up a user by their WINNT:\\DOMAIN\USERACCOUNT. The site is authenticating the users (it's a CMS site and they must be authenticated). I have Integrated Authentication & Anon access checked in IIS. I also have the following in my web.config: <authentication...
5
1505
by: Tim::.. | last post by:
Hi can someone please tell me how I change this directory service query so that it searches through each record in the active directory and returns all the accounts! At the moment I can only get the query to return one account at a time! I presume I have to create some kind of loop on the following so I return all the users SAM info???? ...
6
2397
by: Leo_Surf | last post by:
Hello, I need your help adding user in Active Directory from ASP.net website. Could any one provide me the complete code for the html page. As this is my curriculam project and I dont have any Idea about ASP.net Please Help Thanks in Advance.
3
3465
by: Luis Esteban Valencia | last post by:
Hello gusys, Is it possible to make my asp.net application add users to the AD , I also want to be able to delete users, modify their information, everything through a website. Thanks for the info
1
3886
by: tangus via DotNetMonster.com | last post by:
Hello all, I'm really struggling with getting some Active Directory code to work in ASP.NET. Can you please provide assistance? I am executing the following code: Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://domain") Dim mySearcher As New DirectorySearcher(enTry) Dim resEnt As SearchResult mySearcher.Filter =...
10
4038
by: Hriday | last post by:
Hi there, Please help me..It is urgent This is Hriday, working on windows authentication with Active Directory... My requirment is when a user sends a request to my web Applicatoin I want to Pop up windows Authentication box so that user will give his userId, Password & domain name for authenticaion. After that I want to take these...
0
2732
by: jakobsgaard | last post by:
It is possible to Map a certificate to a Active Directory User Account from DotNet? Please provide an example. Best regards, Ejnar Jakobsgaard ------------------------------------------------- To map a certificate to a user account Open Active Directory Users and Computers.
2
2653
by: HamishC | last post by:
Hi all, I have been knocking my head against this one for a few days -- haven't been able to find a solution to this anywhere so hopefully someone can help. Situation: A really simple LDAP that searches for a users AD account - it works for some users, not for others. More bizarrely, for some people it seems to work occassionally. Setup:...
3
3006
by: =?Utf-8?B?YXppZWdsZXI=?= | last post by:
Hello, everybody. I'd like to do this: For a big program (a web service) I need information about the usergroups an active-directory-user is member of. To be more precise, I need to know if a particular user is in a particular group or not. This is my first Active-Directory-query in a C#-program, so it might look crude or primitive...well,...
0
7693
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
7917
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
8118
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
7665
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
7962
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...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
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...
0
3651
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
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.