.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

List of users by department hyperlinked

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :ASP.Net

Hey Guys,

On our intranet site I have a search function to search the users in Active directory and returns certain criteria (phone number, email etc). What I have been asked for next is a list of departments where when clicked it brings up a list of users in that department, this is as far as I have managed to get. What I need to do next is have each user in this list as a hyperlink so that when you click their name it brings up their details.

My code for departmental search is:

  protected void LinkButton1_Click(object sender, EventArgs e)
        SearchResultCollection results = null;
            string path = "LDAP://server.company.company.company/ou=test,DC=company,DC=company,DC=company";
            DirectoryEntry entry = new DirectoryEntry(path);
            DirectorySearcher mySearcher = new DirectorySearcher(entry);
            mySearcher.Filter = "(&(objectClass=user)(|(department=Accounts*)))";
            results = mySearcher.FindAll();
            foreach (SearchResult searchResult in results)
                Console.WriteLine("Search properties for {0}", searchResult.Path);
                foreach (string propertyKey in searchResult.Prope

View Complete Post

More Related Resource Links

Getting users list reporting to manager from LDAP


Dear All,

I need to get list of users reporting to a particular manager from the Active directory.

In the active directory there is manager property with contains the data in the following way.


Please help me in building the filter condition.

I am using the following

pUserName="Gegore Lid";

strSearch = "(&(objectClass=user)(objectCategory=user)((Manager cn=" + pUserName + "))";

DirectorySearcher dSearcher = new DirectorySearcher(dEntry, strSearch);

            //Account properites to load
            string[] arrPropertiesToLoad = { "displayName", "department", "manager", "sAMAccountName", "EmployeeNumber", "Title" };

          SearchResultCollection sResultColl = dSearcher.FindAll();

 the above code is not returning any result.

Please help me in this.



Getting list of users reporting from specific Manager from Active Directory


Dear All,

I am have requirement like displaying all the user information reporting to specific manager from Active Directory.

Please help me regarding this.



List Users from Active Directory


When i try to List the users from Active directory, i get this exception.

Error while processing.System.Runtime.InteropServices.COMException (0x80072020): An operations error occurred at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.DirectorySearcher.FindAll(Boolean findMoreThanOne) at System.DirectoryServices.DirectorySearcher.FindAll()

The code i used is :

DirectoryEntry de = new DirectoryEntry(_path);DirectorySearcher deSearch = new DirectorySearcher();

deSearch.SearchRoot =de;

deSearch.Filter = "(&(objectClass=user) (cn=" + UserName +"))";

SearchResultCollection results = deSearch.FindAll();

 But the DirectoyEntry method is getting validated if i use the overloaded method : DirectoryEntry(_path, domainAndUsername, password);

Please advice me.

Assigning users when creating a list item in a workflow


I'm using a workflow to assign tasks to users.  When I try to assign the task to a group (set in the workflow designer), the workflow gives me an error.  When I change the assign to property to a single user, the workflow works perfectly.  How do I get the workflow to assign the task to the group?  Or if that's not possible, can I get it to assign it to more than one user?


Is there any way to list WebPart's authorised users?


Actually, I set access to some of the WebParts to desired group of SP users. (Web Part edition->Advance->last option on the bottom)

Is there any way to list this access? I'd like to have some kind of list with WebParts and users signed to its.

E-Mail Alerts for users on Task List


Is there any way to send e-mail alerts to a specific user wihtout assigning them the task or having them subscribe to the list.

It's a Task List on WSS 3 on Win2k3 Enterprise'


Customized list views and permissions to specific group users

Hi, I have created a custom list with 20 field/columns in wss3.0. I had four user groups(group1, group2,....3.....4) in my site collection with various levels of permissions. I have created four custom views (Group 1 view, Group2 view,...etc)in my list. Each view contains only certain fields out of 20. For example group 1 view contains field 1, 5, 7,10 and 13 of every item in my list.  My requirement is that when a user login, who is a member of group1. he should be able to view only Group1 view fields. He should not able to view other field/columns. I tried creating another field/column called as restricted users and wrote group names in that. In the View edit page I selected " show item when the column 'restricted users' is equl to [Me]. But I did not get it. Kindly help it out any one either programmatically or UI based. Thanks   

Maintain users and groups list of Active Directory for an asp.net web application only

Hi, I have configured active directory in my server 2008. We have a web project using asp.net mvc named Audit planning and Execution Software(Apex2).What we want to do is to authenticate Active directory users for this project.I can get all active directory users, groups, users of a group etc.I want to add users in active directory for the Apex2 project only using asp.net.I also want to display only the users and groups of Active Directory registered with the Apex2 project only. And I also want to add active directory users from whole AD list to our project's AD list. Can you please tell me, how will I do this. Shall I create an Organizational Unit and maintain all users and groups there for our project? Or, is there any other way to do this?  please help me.Thank You

How can I get a list of users that are able to start/stop/execute jobs on sql server?

I know that the users with sysadmin roles are able to start/stop/execute jobs but I wonder if there are another roles or permissions that enable users to do this.   regards,

How to properly configure permissions so users can view, add, edit, and delete list items, but not w

I am trying to figure out how to properly setup security so that it can be configured at the top-level, and then inherited all the way through. Here is what I would like to do: Each user can view, add, edit, and delete list items - but, users cannot modify or delete web part pages. The only way I know how to do this is set Contribute from the top-down, and then go into each Site Pages library and set Read access. The problem is that I have 100 sites, and I was hoping there was a way I could set security at the top, and inherit downward. Rather than having to go into all 100 Site Pages library and set Read access. Is there a way to do this? Thanks in advance.

Custom Contact List: has to be auto-populated with users and manually insert others contact

Hi All, is it possible to create a custom contact list that automatically insert user as contact? I have to use it to send auto-email to the people in the contact list... (ant they can be user or not) Thanks All Vit

Grab a users/roles list?

Just wondering how to implement a user's list into my website ? im using ASP.NET C#. I want to be able to:add/delete usersadd/remove roles

Make a list field ediable by a group of users or hidden to everyone else.


I understand how to hide a field, but this hides it for everyone. My team want to hide it for the users and show it for our team. The field we want hidden from other users are Assigned to, Due Date, and Due Date, but we want our team to be able to edit these fields; not the other users. Is it any way to do this? Thanks for the help.



Reading users department fails


I'm trying to get the currents users department name in a Sharepoint feature, but I get an error when i try to runthe code :  Here the code: 

private string GetUserIdent(SPWeb web, SPSite site)


stsadm to list users in a group


Hi all,

 Does anybody knows how to enumerate users in a Sharepoint 2007 group ? I have a particular case where users cannot be displayed in the UI.

 The closest I found is Enumusers but it lists users of a site collection or subsite.




Other users added to task list notification


Using SharePoint 2007, MOSS.

A user edits a task that is assigned to him, once the task is updated a new notification email goes out with other people, who aren't assigned to the task. This happens occasionally, not all the time, on several sites. Never the same way twice!

SSIS SharePoint List Adapter - how to query Users & Groups?


I am using SSIS SharePoint List Adapter to load data in and out of my SharePoint Lists from within SSIS, and most of it is working fine.  However, I need to perform a lookup against the Users & Groups collection in SharePoint so I can retrieve the UserID and set the value when writing back to SharePoint.  Any help would be tremendously appreciated!


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend