473,625 Members | 3,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Active Directory Search

radcaesar
759 Recognized Expert Contributor
Hi All,
I had wrote a method to compare the users of AD and a oracle user table. Here using datarow, i search each users in AD.

My code workin fine for first record, but it fails ffom serching the second record onwards.

I was confused why this Findone() mthod returns null from the second record.

Expand|Select|Wrap|Line Numbers
  1. private void GetFDSUsers()
  2.     {
  3.         DirectoryEntry FDSDE = GetFDSObject();
  4.         DirectorySearcher FDSSearcher = new DirectorySearcher();
  5.         DataView dv = (DataView)  CSIDataSource.Select(DataSourceSelectArguments.Empty);
  6.  
  7.         foreach (DataRow dr in dv.Table.Rows)
  8.         {
  9.             string SearchName = dr[0].ToString().ToUpper();
  10.             //string SearchName = "SMANIKA5";
  11.             FDSSearcher.SearchRoot = FDSDE;
  12.             FDSSearcher.Filter = "(&(objectClass=user)(SAMAccountName=" + SearchName + "))";
  13.  
  14.             // FDSSearcher.Filter = "(&(objectClass=user)(SAMAccountName=SMANIKA5))";
  15.  
  16.             FDSSearcher.SearchScope = SearchScope.Subtree;
  17.             SearchResult FDSSearchResult = FDSSearcher.FindOne();
  18.  
  19.  
  20.             if (!(null == FDSSearchResult))
  21.             {
  22.                 FDSDE = new DirectoryEntry(FDSSearchResult.Path, "username", "password", AuthenticationTypes.Secure);
  23.  
  24.                 Response.Write(FDSDE.Name.ToString()+"\r");
  25.                 //Response.Write(FDSDE.Username);
  26.                 Response.Write(FDSDE.Properties["DisplayName"].Value.ToString());
  27.                 //return FDSDE;
  28.             }
  29.             else
  30.             {
  31.                 //Response.Write("Else Part, Record not found");
  32.                 //return null;
  33.             }            
  34.        }
Mar 26 '07 #1
2 1325
radcaesar
759 Recognized Expert Contributor
No Replies Yet ? Its Bad buddies.

I Had solved that and its fine now.

:)
Mar 26 '07 #2
kenobewan
4,871 Recognized Expert Specialist
So you used findall() instead?
Mar 27 '07 #3

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

Similar topics

2
5519
by: Victor Lokhmatov | last post by:
Hello Everyone, My company has asked me to put a company directory on our intranet site and I'm trying to use php to extract the users from our active directory server. I've got everything working, however, when the list of users is shown in the output, it seems to display the users in the order their accounts were created, with Administrator obviously being first. What do you think would be the best way to get the list to be sorted by...
1
3938
by: Toufani | last post by:
Hi everybody, I want to retrieve information about objects in active directory windows 2000 and their properties. I got some codes that don't work absolutely. for example I can't retrieve users list and group list separatedly.there is my code that downloaded from the internet : public class LdapAuthentication { private string _path;
1
3890
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 = ("(objectClass=*)") mySearcher.SearchScope = SearchScope.Subtree
3
2643
by: Adrian Parker | last post by:
At the moment, we have a simple user id / password entry screen to login to our website, the data credentials are held in our database. We've now been asked to integrate with active directory so that users on the lan who are already logged in via active directory no longer need to log into the website, but automatically are logged in using their network userid (which should match the old website login). I can see how I could prompt for...
10
4046
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 three info of user and make a search in Active Directory.
2
4689
by: P Webster | last post by:
We recently moved a web site that validated user credentials in Active Directory from IIS 5.1 to IIS 6, and the validation code no longer works. The web.config file is set to Windows authentication because all we do is verify the user on the login form so we can redirect them to the appropriate page based on their group. The code to authenticate is: Public Function IsAuthenticated(ByVal domain As String, ByVal username As String, ByVal...
0
1337
by: Matt | last post by:
Hi, I am looking for an Active Directory object selection for ASP.net 2. My ASP.net page has a text field to enter a user's or computer's LDAP path directly. And a "Find..." button that shall display an Active Directory search GUI like the dialog shown on a Windows Server 2003 under "Active Directory Users and Computers - Find...". I could not find an ASP.net server control for this. I know that I can search the Active Directory using...
8
14198
by: Mr. Bean | last post by:
Hello, I'm trying to retrieve the user's properties from Active Directory. I was able to retrieve all the user properties, however, I wassnt able to get the manager's user name. What I got was the path of the user name : CN="Display Name", CN=myCompany,CN=COM.. Here is the private string FindProps(String userAccount)
2
5959
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could use the System.DirectoryServices.ActiveDirectory namespace. I don't even know if this is the right way to go as I can't seem to find anything in that namespace that would help me query active directory for names. I can't use an LDAP query...
0
5406
by: Chung Leong | last post by:
In this brief tutorial I'll describe how you retrieve information from an Active Directory through the OLE-DB extension. While it is possible to use the LDAP extension to achieve the same goal, as you will see using Microsoft's OLE-DB provider is much easier. You will need to download and install the OLE-DB extension. Here's the location once again: http://sourceforge.net/project/showfiles.php?group_id=171247&package_id=198554. See my...
0
8189
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
8692
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
8635
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...
1
8354
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
6116
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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();...
1
2621
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
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
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.