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.
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.
Code:
private void GetFDSUsers()
{
DirectoryEntry FDSDE = GetFDSObject();
DirectorySearcher FDSSearcher = new DirectorySearcher();
DataView dv = (DataView) CSIDataSource.Select(DataSourceSelectArguments.Empty);
foreach (DataRow dr in dv.Table.Rows)
{
string SearchName = dr[0].ToString().ToUpper();
//string SearchName = "SMANIKA5";
FDSSearcher.SearchRoot = FDSDE;
FDSSearcher.Filter = "(&(objectClass=user)(SAMAccountName=" + SearchName + "))";
// FDSSearcher.Filter = "(&(objectClass=user)(SAMAccountName=SMANIKA5))";
FDSSearcher.SearchScope = SearchScope.Subtree;
SearchResult FDSSearchResult = FDSSearcher.FindOne();
if (!(null == FDSSearchResult))
{
FDSDE = new DirectoryEntry(FDSSearchResult.Path, "username", "password", AuthenticationTypes.Secure);
Response.Write(FDSDE.Name.ToString()+"\r");
//Response.Write(FDSDE.Username);
Response.Write(FDSDE.Properties["DisplayName"].Value.ToString());
//return FDSDE;
}
else
{
//Response.Write("Else Part, Record not found");
//return null;
}
}
Comment