473,397 Members | 2,084 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,397 software developers and data experts.

How to search in Active Direcoty

Hi there,
I am working on a web application in ASP.NET
My web server and AD machine are in the same domain but
located on diffrent phisical machine, I am not able to
search user's info by the following code if I pass only
path as parameter to DirectoyEntry class. The same code is
working if I pass all the three parameter as path,userId
and password. but I have to use windows authenticatoin and
can't get password from Windows
authenticatoin Popup box.....

I think I should be able to search in AD by only having
complete LDAP path and Username. I copy the complete code
here...I get System.Runtime.InteropServices.COMException
error on following line
Dim obj As Object = entry.NativeObject

Any help sincerelly appriciated...

COMPLETE CODE IS LIKE THIS...

Private path As String
= "LDAP://AD/DC=AD,DC=MyComp,DC=COM"
Private filterAttribute As String
Public fullname As String
Public groupName As String
Public email As String

Public Sub GetUserDetails(ByVal domain As String, ByVal
username As String) ', ByVal pwd As String)
Dim domainAndUsername As [String] = domain & "\" &
username
Dim entry As New DirectoryEntry(path) ',
domainAndUsername, pwd)

Try
'Bind to the native AdsObject to force
authentication.
Dim obj As Object = entry.NativeObject

Dim search As New DirectorySearcher(entry)

search.Filter = "(SAMAccountName=" & username
& ")"
search.PropertiesToLoad.Add("cn")
Dim result As SearchResult = search.FindOne()

'Update the new path to the user in the
directory.
path = result.Path
filterAttribute = CType(result.Properties("cn")
(0), String)
fullname = CType(result.Properties("cn")(0),
String)
search.PropertiesToLoad.Add("mail")
Dim resultemail As SearchResult =
search.FindOne()
email = CType(resultemail.Properties("mail")
(0), String)

search.PropertiesToLoad.Add("MemberOf")
Dim resultgp As SearchResult = search.FindOne()
groupName = CType(resultgp.Properties
("MemberOf")(0), String)

Catch ex As Exception
Throw New Exception("Error obtaining user
details. " + ex.Message)
End Try

End Sub 'GetUserDetails
..
Nov 20 '05 #1
0 1062

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

Similar topics

3
by: Dirk Hagemann | last post by:
Hi! I asked here a few weeks ago the same question but the answer of Tim Golden didn't really help yet. I'd like to know how to set up a query for all computer-accounts in a special part of...
3
by: Ivan G. | last post by:
Hi. I'm trying to search active directory for users like this: DirectoryEntry entry = new DirectoryEntry(); //use default domain DirectorySearcher searcher = new DirectorySearcher(entry,...
0
by: Glen Darling | last post by:
Morning everyone, I am looking for help with an active directory search I am trying to figure out. For a while now I have been banging my head against a wall trying to figure out how to...
7
by: Matt Kruse | last post by:
Javascript "Knowledge Base" Search: http://www.javascripttoolbox.com/search/ Responses to questions on this group are often along the lines of "did you read the FAQ" or "did you search the...
2
by: sgr | last post by:
How do I search an user into the active directory from a c# application? Thanks for all.
3
by: MuZZy | last post by:
Hi, I'm trying to find a way to call a standard ActiveDirectory search dialog from my C# app, so i can pick a domain or computer user an dreturn it to the app. It's a search like one showing...
9
by: AMBLY | last post by:
Hello ! Hope someone might be able to help me with this one. I run Access2000 on XP. I have a form : frmONE- which contains a txt field: ctrCTN from my table/database. The values in ctrCTN are...
0
by: fabiomoggi | last post by:
Hello Guys, I am developing a web application to manage Active Directory resources, and one of my tasks is to map Organizational Units hierarchy into a SQL Server database. Let's suppose that I...
3
by: helpmeplease213 | last post by:
Is there a way that I can search whole words in a line rather than just search every letter. ie when I am searching I will type AC (air conditioning) in a text box to search for only AC words but...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...
0
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...
0
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,...
0
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...

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.