DanEvansJr
Programmer
First off, let me say in advance that I am EXTREMELY new to .NET, C#, ASP and true object oriented programming in general. My background is relational databases/Xbase, so be gentle and feel free to dumb it down for me. I won't be offended.
Secondly, Thank you for viewing this thread. Any help that you can give will be greatly appreciated.
Currently, we're using LDAP to authenticate users through a web page. We are upgrading our applications to authenticate against Active Directory and I have been tasked to do this. I have a login page that accepts a standard user/pass. I can successfully detect the Active Directory server and confirm the user id and password against my two input fields. And I can get group membership status for the logged in user, but if the logged in user is different than the user ID in the text field my code is only looking for the user that is physically logged into the machine, ignoring the input field.
EX: If JSMITH is logged into the machine, and he types HIS user/pass, assuming he is a member of that ADMINS group, he will proceed to the application main page. But if TJONES types his user/pass while on JSMITH's machine, TJONES will be granted access regardless of his group membership because the code is searching based on the machine user and not the user ID text field.
I've included the code below. I'm assuming that it has something to do with the foreach line, but I don't know enough to be sure.
Thank you,
Dan Evans Jr.
//***** begin C# code ***********
public bool GetGroups()
{
bool groupfound = false;
string GroupString;
foreach (System.Security.Principal.IdentityReference group in System.Web.HttpContext.Current.Request.LogonUserIdentity.Groups)
{
GroupString = group.Translate(typeof(System.Security.Principal.NTAccount)).ToString();
if (GroupString.Contains("ADMINS"))
{
groupfound = true;
}
}
return groupfound;
}
//******************************
Secondly, Thank you for viewing this thread. Any help that you can give will be greatly appreciated.
Currently, we're using LDAP to authenticate users through a web page. We are upgrading our applications to authenticate against Active Directory and I have been tasked to do this. I have a login page that accepts a standard user/pass. I can successfully detect the Active Directory server and confirm the user id and password against my two input fields. And I can get group membership status for the logged in user, but if the logged in user is different than the user ID in the text field my code is only looking for the user that is physically logged into the machine, ignoring the input field.
EX: If JSMITH is logged into the machine, and he types HIS user/pass, assuming he is a member of that ADMINS group, he will proceed to the application main page. But if TJONES types his user/pass while on JSMITH's machine, TJONES will be granted access regardless of his group membership because the code is searching based on the machine user and not the user ID text field.
I've included the code below. I'm assuming that it has something to do with the foreach line, but I don't know enough to be sure.
Thank you,
Dan Evans Jr.
//***** begin C# code ***********
public bool GetGroups()
{
bool groupfound = false;
string GroupString;
foreach (System.Security.Principal.IdentityReference group in System.Web.HttpContext.Current.Request.LogonUserIdentity.Groups)
{
GroupString = group.Translate(typeof(System.Security.Principal.NTAccount)).ToString();
if (GroupString.Contains("ADMINS"))
{
groupfound = true;
}
}
return groupfound;
}
//******************************