473,785 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.NativeObj ect

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 domainAndUserna me As [String] = domain & "\" &
username
Dim entry As New DirectoryEntry( path) ',
domainAndUserna me, pwd)

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

Dim search As New DirectorySearch er(entry)

search.Filter = "(SAMAccountNam e=" & username
& ")"
search.Properti esToLoad.Add("c n")
Dim result As SearchResult = search.FindOne( )

'Update the new path to the user in the
directory.
path = result.Path
filterAttribute = CType(result.Pr operties("cn")
(0), String)
fullname = CType(result.Pr operties("cn")( 0),
String)
search.Properti esToLoad.Add("m ail")
Dim resultemail As SearchResult =
search.FindOne( )
email = CType(resultema il.Properties(" mail")
(0), String)

search.Properti esToLoad.Add("M emberOf")
Dim resultgp As SearchResult = search.FindOne( )
groupName = CType(resultgp. Properties
("MemberOf")(0) , String)

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

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

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

Similar topics

3
7206
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 Active Directory by using LDAP. Example: all computers with a name like "ABC*" at "..., ou=Production,
3
3714
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, "(|(objectclass=person)(objectclass=user))"); SearchResultCollection result = searcher.FindAll();
0
1056
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 differentiate between a regular computer and a server in Active Directory. To date I have not been able to come up with anything that functions 100% and have had to utilize OU's for servers in order to get that list. This is ok if you are a 100%...
7
1498
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 archives?" or "did you do a google search?". To regular readers and experienced javascript developers, knowing how and where to search and filtering out junk results is an easy task. For most javascript users, however, it's not so easy.
2
1867
by: sgr | last post by:
How do I search an user into the active directory from a c# application? Thanks for all.
3
5794
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 when you call: rundll32 dsquery,OpenQueryWindow I'm sure there is a Win32 API method to do that but i can't find one.
9
2813
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 unique. Next to this field is a cmdFIND button frmONE is open and the active window. I want to search for values in ctrCTN, and go to the record which contains that value. I do not want to use a cmdButton with in-built Access Find procedure to...
0
1358
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 have the following OU hierarchy in my Active Direcoty: 1. NewYork -----1.1 HR_Department ----------1.1.1 Computers ----------1.1.2 Users -----1.2 SALES_Department ----------1.2.1 Computers
3
1091
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 my code returns every two letters together that are ac therefore I will get "accept", "active" etc. but I only want AC as a whole word. But I also want it anywhere in the line so if I have the line "The AC is no longer active" I want it to...
0
9646
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9484
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10350
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9957
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6742
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2887
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.