0

I do have a intranet web application which should be deployed at the client ,i am not aware of the users and roles at the client.Right now i am able to communicate with Active Directory in my development environment in vs2008 in my local system.I am able to authenticate against particular users in my development environment.

I am little confused here in understanding how the actual deployment scenario works with the Active directory.I do have experience with sqlserver DB where super user can add users then assign roles to them.(Thats how my application works)

But in real time scenario how does the active directory authentication works after the deployment as i don't visit the client location to deploy the intranet application.I am completely unaware of the users or their roles or groups in the active directory ?

Is there a general scenario i can work on so that i can implement the active directory scenario ?

Macnique
  • 1,028
  • 2
  • 19
  • 44

1 Answers1

2

Seeing as this is an intranet application you should probably use Windows Authentication. In the IIS hosting the application Windows Authentication should be set to enabled and the IIS will use active directory to authenticate users.

Call this code

IPrincipal credentials = (IPrincipal)HttpContext.Current.User;
bool isAuthenticated = false;
if (credentials != null)
{
    WindowsIdentity identity = (WindowsIdentity)credentials.Identity;
    isAuthenticated = identity.IsAuthenticated;
}
if (isAuthenticated != null)
{ //do what needs to be done }

when you need to authenticate a user and he will be presented with a windows log in form in which he can enter his active directory controlled account credentials.

Good luck

Constantin
  • 465
  • 4
  • 18
  • :I did try that way but it asks for credentials only once when you start the application.But once you log out of the application it doesn't prompt you for the credentials again as you are already logged into the system or computer .I hope you got my point here. – Macnique Nov 01 '11 at 15:46
  • Yes, I understand, but why is that a problem? If there are multiple user on the same machine then you could make the users log out as described here http://stackoverflow.com/questions/1067263/asp-net-windows-authentication-logout. – Constantin Nov 01 '11 at 15:51