Click here to Skip to main content
11,637,415 members (65,072 online)
Rate this: bad
good
Please Sign up or sign in to vote.
I'm writing a web-app that is required to present users with a login screen.

Users can enter username/password and select a domain from a dropdown list.

how to enumerate all available domains in the server's AD forest even before user login after basic authentication? I came to know that it should be coded in Application_Start. But dont know how and what to do?

Here is my login web form which should authenticate in Active Directory

<fieldset>
        <legend>Log in Form</legend>
how to give here with a dropdown list under user name and password and should populate with list of all available domains...?

Please guide me..

Kindest Regards
Karthik
Posted 14-May-13 1:05am
Edited 14-May-13 3:04am
vijay__p5.1K
v2
Comments
David_Wimbley at 14-May-13 13:45pm
   
Can you post the code that you have currently to get all available domains from servers AD forrest? You say you've got it implemented in your Application_Start but it would have to be in the controller and returned using a model to your view...not your app_start method.
sarvankarthik at 14-May-13 13:48pm
   
Domain domain = Domain.GetDomain(new DirectoryContext(DirectoryContextType.Domain, "yourDomain", "username", "password"));

Forest forest = domain.Forest;

DomainCollection domains = forest.Domains;



this is the code that enumerate domains from AD.. But how to place this code in MVC approach and how to link it to html dropdownlist helper..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Sorry, i just saw you replied. Thanks first of all.

Will try and get back to you.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 314
1 OriginalGriff 295
2 stibee 288
3 jyo.net 270
4 himanshu agarwal 209
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,643
2 Mika Wendelius 6,959
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320


Advertise | Privacy | Mobile
Web04 | 2.8.150728.1 | Last Updated 27 Apr 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100