473,386 Members | 1,598 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,386 software developers and data experts.

Active Directory Search

radcaesar
759 Expert 512MB
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 1319
radcaesar
759 Expert 512MB
No Replies Yet ? Its Bad buddies.

I Had solved that and its fine now.

:)
Mar 26 '07 #2
kenobewan
4,871 Expert 4TB
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
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...
1
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...
1
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 =...
3
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...
10
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...
2
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...
0
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...
8
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...
2
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.