473,569 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#-web: Reading Users Of Active Directory

31 New Member
Hi All,

I am using the DirectorySearch er class for reading the active directory users. But the result shows the IUSR accounts also.

I dont want to take the IUSR accounts.

So please help me to take the usernames with out IUSR accounts from the active directory.

Is any attributes for remove those IUSR accounts?

Thanks in Advance.

Regards,
Dhanasekaran. G
Feb 19 '08 #1
5 7693
Plater
7,872 Recognized Expert Expert
Do a post process on your data, removing the IUSER accounts?
Offhand I don't know of any attributes, but you could look at them in windows and see if there is anything in common
Feb 19 '08 #2
mikeyeli
63 New Member
Hi All,

I am using the DirectorySearch er class for reading the active directory users. But the result shows the IUSR accounts also.

I dont want to take the IUSR accounts.

So please help me to take the usernames with out IUSR accounts from the active directory.

Is any attributes for remove those IUSR accounts?

Thanks in Advance.

Regards,
Dhanasekaran. G
you must specify what you want at the DIrectorySearch er filter
ex C#:
Expand|Select|Wrap|Line Numbers
  1. search.Filter = "(&(objectClass=user)(objectCategory=person))";
Here is an example:
Expand|Select|Wrap|Line Numbers
  1. public static ArrayList GetAllADDomainUsers(string domainpath)
  2. {
  3.         ArrayList allUsers = new ArrayList();
  4.         DirectoryEntry searchRoot;
  5.  
  6.         searchRoot = new DirectoryEntry(domainpath);
  7.  
  8.         DirectorySearcher search = new DirectorySearcher(searchRoot);
  9.         search.Filter = "(&(objectClass=user)(objectCategory=person))";
  10.         search.PropertiesToLoad.Add("samaccountname");
  11.  
  12.         SearchResult result;
  13.         SearchResultCollection resultCol = search.FindAll();            
  14.  
  15.         if (resultCol != null)
  16.         {
  17.                 for(int counter=0; counter < resultCol.Count; counter++)
  18.                 {
  19.                         result = resultCol[counter];
  20.                         if (result.Properties.Contains("samaccountname"))
  21.                         {
  22.                                 allUsers.Add((String)result.Properties["samaccountname"][0]);
  23.                         }
  24.                 }
  25.         }
  26.         return allUsers;
  27. }
Feb 19 '08 #3
dhanashivam
31 New Member
Hi,

thanks for your reply. But still i am getting the following user accounts.

IWAM_DOMAINCS, IUSR_DOMAINCS,

my code is:

DirectorySearch er Searcher = new DirectorySearch er();
Searcher.Search Scope = SearchScope.Sub tree;
Searcher.Proper tiesToLoad.Add( "sAMAccountName ");
Searcher.Filter = "(&(objectClass =user)(objectCa tegory=person)) ";

DataTable dtUsers = new DataTable("User InAD");
dtUsers.Columns .Add("uname");
string str = "";
foreach (SearchResult AdObj in Searcher.FindAl l())
{
str += Convert.ToStrin g(AdObj.Propert ies["sAMAccountName "][0]) + "\n";
DataRow dr = dtUsers.NewRow( );
dr[0] = Convert.ToStrin g(AdObj.Propert ies["sAMAccountName "][0]);
dtUsers.Rows.Ad d(dr);
}

please help me.

thanks in advance.

Regards,
Dhanasekaran. G
Feb 20 '08 #4
mikeyeli
63 New Member
Hi,

thanks for your reply. But still i am getting the following user accounts.

IWAM_DOMAINCS, IUSR_DOMAINCS,

my code is:

DirectorySearch er Searcher = new DirectorySearch er();
Searcher.Search Scope = SearchScope.Sub tree;
Searcher.Proper tiesToLoad.Add( "sAMAccountName ");
Searcher.Filter = "(&(objectClass =user)(objectCa tegory=person)) ";

DataTable dtUsers = new DataTable("User InAD");
dtUsers.Columns .Add("uname");
string str = "";
foreach (SearchResult AdObj in Searcher.FindAl l())
{
str += Convert.ToStrin g(AdObj.Propert ies["sAMAccountName "][0]) + "\n";
DataRow dr = dtUsers.NewRow( );
dr[0] = Convert.ToStrin g(AdObj.Propert ies["sAMAccountName "][0]);
dtUsers.Rows.Ad d(dr);
}

please help me.

thanks in advance.

Regards,
Dhanasekaran. G
You're right, ive been searching, cant find a way to directly removing them on the filter, i think you should follow platers advice, do some post proccess to remove these accounts, although you have to think a way to make this efficient, since there can be a considerable amount of users. sorry i couldnt help
Feb 21 '08 #5
Plater
7,872 Recognized Expert Expert
I think there is a way to use SQL to query against active directory. (I saw it somewhere burried in msdn once i think)
That might be useful to throw in a "WHERE UserName NO like 'IUSER%' " or something.
Maybe you can do that with DirectorySearch er too though?
Feb 22 '08 #6

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

Similar topics

15
3868
by: scmiles | last post by:
I am trying to write an asp or aspx page that will create a virtual ftp directory to the users Active Directory home directory. That way a user can interact (drag/drop, copy/paste) via IE with folder view for ftp sites. I have some code, that seems to be "flaky" it works for me and some others, but not everyone. I really need to get a...
3
3465
by: Luis Esteban Valencia | last post by:
Hello gusys, Is it possible to make my asp.net application add users to the AD , I also want to be able to delete users, modify their information, everything through a website. Thanks for the info
1
3886
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 =...
4
2341
by: Patrick.O.Ige | last post by:
If i want to generate a menu structure depending on who is logged in in an intranet system(using windows authentication) is it better to use the GROUPS in Active Directory or to move the Active Directory groups into a Sql Server database and base the authrorization and authentication on the SQL Server roles/groups? Whats the best way to make...
2
3230
by: Jm | last post by:
Hi All Im not sure of which way to go about this so ill start by explaining what im trying to do and the options ive come up with. ok.. I have a client program which talks to an sql server database whenever a machine is turned on. It reports the client machine status to the server and accepts incoming tcp connections for various...
1
1530
by: Lucky | last post by:
hi guys, after long long efforts i got access to the active directory for "Intigrated windows authentication". now i', suppose to get access the network resources. the problem is i'm getting access to the active directory but when i search for some users into the active directory, it returns none though there are more then 42 users exists....
2
5955
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...
2
1823
by: catherine | last post by:
Hi, I am trying to work out how I can disable / enable **another** users Active Directory account not my own via C#. If I create a directory entry like so I need to know the other users password befoew I can do anything with the user. Obviously I will not know this information DirectoryEntry de = new DirectoryEntry(); de.Path =...
0
7614
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...
0
7924
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. ...
1
7676
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...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
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...
0
5219
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...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
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
0
938
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...

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.