PC Review


Reply
Thread Tools Rate Thread

ASP.NET C# GetObject

 
 
LamSoft
Guest
Posts: n/a
 
      6th Jun 2007
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


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      6th Jun 2007
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();

 
Reply With Quote
 
LamSoft
Guest
Posts: n/a
 
      6th Jun 2007
May I know how to know the return code?
Thank you
"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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();
>



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      6th Jun 2007
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:(E-Mail Removed)...
>
>
>
> > 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;
}

 
Reply With Quote
 
LamSoft
Guest
Posts: n/a
 
      6th Jun 2007
Thanks a lot
"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:(E-Mail Removed)...
>>
>>
>>
>> > 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;
> }
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getobject Brennan Microsoft Access 6 12th Jul 2008 02:20 AM
GetObject Maxi Microsoft Excel Programming 0 14th Mar 2006 10:23 AM
Using getObject() AP Microsoft Dot NET 0 17th Sep 2005 04:35 PM
GetObject?? perspolis Microsoft C# .NET 3 12th Feb 2005 02:41 PM
GetObject Michael Microsoft Excel Programming 3 16th Jun 2004 01:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:28 AM.