Re: Changing windows passwords remotely
- From: "dlinetsky@xxxxxxxxx" <dlinetsky@xxxxxxxxx>
- Date: 16 Aug 2005 11:53:32 -0700
I don't want you to write any code for me, I just want a suggestion
about how to proceed or a web resource that dicusses the subject. I'm
not using sql server to store credentials, I'm using windows integrated
authentication so I need to be able to access active directory and
change windows acoount passwords remotely using a web form. Here is
the code from my login page to give you an idea of what I'm doing:
void Login_Click(Object sender, EventArgs e)
{
String adPath = "LDAP://... /DC=...,DC=..."; //Path to my LDAP
directory server
LdapAuthentication adAuth = new LdapAuthentication(adPath);
try
{
if(true == adAuth.IsAuthenticated(domain.Text, userName.Text,
password.Text))
{
String groups = adAuth.GetGroups();
//Create the ticket, and add the groups.
bool isCookiePersistent = false; //chkPersist.Checked;
FormsAuthenticationTicket authTicket = new
FormsAuthenticationTicket(1, userName.Text,
DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent,
groups);
//Encrypt the ticket.
String encryptedTicket = FormsAuthentication.Encrypt(authTicket);
//Create a cookie, and then add the encrypted ticket to the
cookie as data.
HttpCookie authCookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
if(true == isCookiePersistent)
authCookie.Expires = authTicket.Expiration;
//Add the cookie to the outgoing cookies collection.
Response.Cookies.Add(authCookie);
//You can redirect now.
Response.Redirect(FormsAuthentication.GetRedirectUrl(userName.Text,
false));
}
else
{
errorLabel.Text = "Authentication did not succeed. Check user
name and password.";
}
}
catch(Exception ex)
{
errorLabel.Text = "Error authenticating. " + ex.Message;
}
}
.
- Follow-Ups:
- Re: Changing windows passwords remotely
- From: Willy Denoyette [MVP]
- Re: Changing windows passwords remotely
- From: Bob Powell [MVP]
- Re: Changing windows passwords remotely
- References:
- Changing windows passwords remotely
- From: dlinetsky@xxxxxxxxx
- Re: Changing windows passwords remotely
- From: Amir Ghezelbash
- Changing windows passwords remotely
- Prev by Date: RE: Help with String.Format
- Next by Date: Re: ReportDocument
- Previous by thread: Re: Changing windows passwords remotely
- Next by thread: Re: Changing windows passwords remotely
- Index(es):
Relevant Pages
|