Re: ADSI - Able to authenticate but unable to get memberOf informa
- From: deltalimagolf <deltalimagolf@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 18 Apr 2008 09:36:01 -0700
The DuplicateToken was left over from the impersonation (I orginally got it
from an example I found). I changed the logon type to Network, it works
great on my local box but now the LogonUser method returns false (when
deployed to the server in the DMZ).
Current clkLogin method -
protected void clkLogin(object sender, EventArgs e)
{
IntPtr iptrUserToken = IntPtr.Zero;
try
{
bool bAuthenticated =
LDAP.LogonUser(txtUserName.Text,
GatewayAdministrationWebConfig.AuthenticationDomain, txtPassword.Text,
LDAP.LogonSessionType.Network, LDAP.LogonProvider.Default, out
iptrUserToken);
if (!bAuthenticated)
{
return;
}
else
{
using (WindowsIdentity winIdentity = new WindowsIdentity(iptrUserToken))
{
IdentityReferenceCollection colRefIdentity =
winIdentity.Groups.Translate(typeof(NTAccount));
foreach (IdentityReference refIdentity in colRefIdentity)
{
if (refIdentity.Value.ToUpper().CompareTo([AD Group]) == 0)
{
FormsAuthenticationTicket authTicket =
new FormsAuthenticationTicket(1,
txtUserName.Text,
DateTime.Now,
DateTime.Now.AddMinutes(60),
false,
string.Empty);
string sTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie cookieTicket = new
HttpCookie(FormsAuthentication.FormsCookieName, sTicket);
Response.Cookies.Add(cookieTicket);
Response.Redirect(FormsAuthentication.GetRedirectUrl(txtUserName.Text, false));
break;
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
finally
{ // Free the tokens
if (iptrUserToken != IntPtr.Zero)
LDAP.CloseHandle(iptrUserToken);
}
}
"Joe Kaplan" wrote:
I don't understand why you are calling DuplicateToken. You don't need that,
do you? You also don't use the token for building the WindowsIdentity in
the code below, so that is a little strange.
I think the main problem is that you are using the NewCredentials logon type
here. That type of token only transitions to the user's token when you use
the network. For a local token, you should use Network logon type.
Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
.
- Follow-Ups:
- Re: ADSI - Able to authenticate but unable to get memberOf informa
- From: Joe Kaplan
- Re: ADSI - Able to authenticate but unable to get memberOf informa
- References:
- ADSI - Able to authenticate but unable to get memberOf information
- From: deltalimagolf
- Re: ADSI - Able to authenticate but unable to get memberOf information
- From: Joe Kaplan
- Re: ADSI - Able to authenticate but unable to get memberOf informa
- From: deltalimagolf
- Re: ADSI - Able to authenticate but unable to get memberOf informa
- From: Joe Kaplan
- Re: ADSI - Able to authenticate but unable to get memberOf informa
- From: deltalimagolf
- Re: ADSI - Able to authenticate but unable to get memberOf informa
- From: Joe Kaplan
- ADSI - Able to authenticate but unable to get memberOf information
- Prev by Date: Re: ADSI - Able to authenticate but unable to get memberOf informa
- Next by Date: Re: ADSI - Able to authenticate but unable to get memberOf informa
- Previous by thread: Re: ADSI - Able to authenticate but unable to get memberOf informa
- Next by thread: Re: ADSI - Able to authenticate but unable to get memberOf informa
- Index(es):
Relevant Pages
|
|