Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET C# GetObject

Reply
Thread Tools

ASP.NET C# GetObject

 
 
LamSoft
Guest
Posts: n/a
 
      06-06-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
 
      06-06-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
 
      06-06-2007
May I know how to know the return code?
Thank you
"Alexey Smirnov" <> 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();
>



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      06-06-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: 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;
}

 
Reply With Quote
 
LamSoft
Guest
Posts: n/a
 
      06-06-2007
Thanks a lot
"Alexey Smirnov" <> wrote in message
news: ups.com...
> 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;
> }
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 in C# manuadoor ASP .Net 0 05-04-2007 06:47 AM
GetObject method in C# manuadoor Software 0 05-04-2007 06:44 AM
Try/Except for ADSI GetObject LittlePython Python 1 06-01-2006 03:35 AM
Garbage from resourceBundle.getObject() for Japanese Delia Java 4 11-19-2004 12:44 PM
Getobject C# Equevlent ]-[aTc]-[ ASP .Net 3 07-17-2004 10:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57