Hello community! My first post here. (might probably have been under c#.. filename.asp.cs)

I have a web AD management project undergoing as I am currently at testing.. the interface *yay*

Extent of the project; pulling a list of employees managed by Mr X. Edit specific fields.

I'm building my interface through the on_load() where I call two methods

protected void Page_Load(object sender, EventArgs e)
        {
//Object that connects to my AD.
            ActiveDirectoryWrapper adWrapper = new ActiveDirectoryWrapper();
         //Get the manager name - didn't hook it up from the session here since I'm testing this form only.   
[INDENT][/INDENT]adWrapper.PopulateUserDataStruct(adWrapper.GetUserDirectoryEntryDetails("MrX"));
            foreach (SearchResult result in adWrapper.GetEmployeesOf(adWrapper.trunkateADSpath(adWrapper.userData.adsPath)))
            {
                ResultPropertyCollection myResultPropColl;
                myResultPropColl = result.Properties;
                if (myResultPropColl.Contains("sAMAccountName"))
                {                                    
                    ActiveDirectoryWrapper employee = new ActiveDirectoryWrapper();
                    employee.PopulateUserDataStruct(employee.GetUserDirectoryEntryDetails(result.Properties["sAMAccountName"][0].ToString()));
                    //Adding only the account name to a public list, it is used in conjucture with the TextBox fields.
                    empList.Add(employee.userData.accountName);
                   
//This method builds the interface for each employee with txtbox editable or not and checkbox editable or not. Each Control has an ID ("controlName"+"i"), runat="server"
                    addEmployeeToTableUI( employee, i.ToString());
                } //end if
            }

It works fine, events are added to each control using the

txtboxName.TextChanged+= new EventHandler(this."event_method_name");

Sum it up, I have bunch of textbox and checkbox and radiobutton with each an EventHandler and AutoPostBack.

Problem: when there's a change, I think the AD members are not getting picked up in the same order, since the user name order differs (I'm trying to sort it alphabetically right now). So, I have an order user1, user2, user3 all being generated with their AD attributes. textchange pops up, modification is done in AD, page reloads leaving the txtbox field in the same order while picking a different order for the members.

I might have already resolve the problem with the alphabetic order I'm undergoing with, but if you have another solution (another method than on_load) that you know refreshes from the ground up on POST, it'd be great to know.

Turns out the sort option from DirectoryEntries is very capricious;

DirectorySearcher search = new DirectorySearcher();
            search.Filter = String.Format("(manager={0})", managerName);
            search.Sort = new SortOption("sn", SortDirection.Descending);

I managed to sort the search using "sn" property, but using "sAMAccoutname", it wouldn't work. There must be some sort of case sensitivity, but I don't feel like trying every possibility.

Company will just have to suck it up resort to Surname sort!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.