Re: Changing windows passwords remotely
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Tue, 16 Aug 2005 22:01:56 +0200
Use the System.Directory namespace classes like you did, but invoke the
native method to change the password of a user like this.
UserEntry is a DirectorEntry object reference that points to the user
account entry in the AD.
object[] password = new object[] {"oldpwd", "newPwd"};
object ret = userEntry.Invoke("ChangePassword", password );
userEntry.CommitChanges();
....
Willy.
<dlinetsky@xxxxxxxxx> wrote in message
news:1124218412.519223.235750@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>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: dlinetsky@xxxxxxxxx
- Re: Changing windows passwords remotely
- References:
- Changing windows passwords remotely
- From: dlinetsky@xxxxxxxxx
- Re: Changing windows passwords remotely
- From: Amir Ghezelbash
- Re: Changing windows passwords remotely
- From: dlinetsky@xxxxxxxxx
- Changing windows passwords remotely
- Prev by Date: RE: datasets, datagrids, and datatables
- Next by Date: Re: Changing windows passwords remotely
- Previous by thread: Re: Changing windows passwords remotely
- Next by thread: Re: Changing windows passwords remotely
- Index(es):
Relevant Pages
|