On Jun 6, 9:55 am, "LamSoft" <[nospam]lams...@lamsoft.net> wrote:
> May I know how to know the return code?
> Thank you"Alexey Smirnov" <alexey.smir...@gmail.com> wrote in message
>
> news: ups.com...
>
>
>
> > On Jun 6, 6:22 am, "LamSoft" <[nospam]lams...@lamsoft.net> wrote:
> >> I want to write a ASPX C# to change the password of a user account on
> >> standalone computer,
>
> >> I have the ASP code on my friend, but I don't know how to convert them to
> >> ASP.NET C#.
>
> >> Is there any reference on the web? Thank you.
>
> >> ASP Code Reference:
> >> Set UsrObj = GetObject("WinNT://" & ServerName & "/" & UserName
> >> ,user)
> >> UsrObj.SetPassword NewPwd
> >> UsrObj.SetInfo
>
> >> If Err.Number = 0 Then
> >> OutMsg("The password of " & UserName & " was successfully
> >> changed.")
> >> Else
> >> OutMsg("Unexpected Error: " & Err.Number & ", Please contact the
> >> webmaster.")
> >> End If
>
> > To access WinNT provider intetrface you should use
> > System.DirectoryServices namespace
>
> > using System.DirectoryServices;
>
> > DirectoryEntry myDirectoryEntry;
>
> > myDirectoryEntry = new DirectoryEntry(@"WinNT://" + ServerName + "/" +
> > UserName + ",User");
> > myDirectoryEntry.Invoke("setPassword", NewPwd);
> > myDirectoryEntry.CommitChanges();- Hide quoted text -
>
> - Show quoted text -
You should catch an exception
try
{
myDirectoryEntry = new DirectoryEntry(@"WinNT://" + ServerName + "/"
+
UserName + ",User");
myDirectoryEntry.Invoke("setPassword", NewPwd);
myDirectoryEntry.CommitChanges();
}
catch (Exception e)
{
OutMsg("Unexpected Error: " & e.ToString() & ", Please contact the
webmaster.");
return;
}
|