Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Asp.Net Programming

ASP.NET C# GetObject


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

On Jun 6, 6:22 am, "LamSoft" <[nospam]lams@lamsoft.net> wrote:

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();

-----------------------------------------------Reply-----------------------------------------------

May I know how to know the return code?
Thank you
"Alexey Smirnov" <alexey.smir@gmail.com> wrote in message

news:1181112149.342131.278600@o5g2000hsb.googlegroups.com...

On Jun 6, 9:55 am, "LamSoft" <[nospam]lams@lamsoft.net> wrote:

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;

Thanks a lot
"Alexey Smirnov" <alexey.smir@gmail.com> wrote in message

news:1181118033.011307.311770@w5g2000hsg.googlegroups.com...

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc