Click here to Skip to main content
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>
        <ol>
            <li>
                @Html.LabelFor(m => m.UserName)
                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)
            </li>
            <li>
                @Html.LabelFor(m => m.Password)
                @Html.PasswordFor(m => m.Password)
                @Html.ValidationMessageFor(m => m.Password)
            </li>
        </ol>
        <input type="submit" value="Log in" />
    </fieldset>
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 2:05am
Edited 14-May-13 4:04am
vijay__p4.7K
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 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 Zoltán Zörgő 99
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 27 Apr 2014
Copyright © CodeProject, 1999-2014
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