By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,423 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

ASP.NET C# GetObject

P: n/a
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
Jun 6 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Jun 6, 6:22 am, "LamSoft" <[nospam]lams...@lamsoft.netwrote:
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();

Jun 6 '07 #2

P: n/a
May I know how to know the return code?
Thank you
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
On Jun 6, 6:22 am, "LamSoft" <[nospam]lams...@lamsoft.netwrote:
>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();

Jun 6 '07 #3

P: n/a
On Jun 6, 9:55 am, "LamSoft" <[nospam]lams...@lamsoft.netwrote:
May I know how to know the return code?
Thank you"Alexey Smirnov" <alexey.smir...@gmail.comwrote in message

news:11**********************@o5g2000hsb.googlegro ups.com...
On Jun 6, 6:22 am, "LamSoft" <[nospam]lams...@lamsoft.netwrote:
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;
}

Jun 6 '07 #4

P: n/a
Thanks a lot
"Alexey Smirnov" <al************@gmail.comwrote in message
news:11**********************@w5g2000hsg.googlegro ups.com...
On Jun 6, 9:55 am, "LamSoft" <[nospam]lams...@lamsoft.netwrote:
>May I know how to know the return code?
Thank you"Alexey Smirnov" <alexey.smir...@gmail.comwrote in message

news:11**********************@o5g2000hsb.googlegr oups.com...
On Jun 6, 6:22 am, "LamSoft" <[nospam]lams...@lamsoft.netwrote:
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;
}

Jun 6 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.