Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / June 2007

Tip: Looking for answers? Try searching our database.

ASP.NET C# GetObject

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LamSoft - 06 Jun 2007 05:22 GMT
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
Alexey Smirnov - 06 Jun 2007 07:42 GMT
> I want to write a ASPX C# to change the password of a user account on
> standalone computer,
[quoted text clipped - 15 lines]
> 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();
LamSoft - 06 Jun 2007 08:55 GMT
May I know how to know the return code?
Thank you
>> I want to write a ASPX C# to change the password of a user account on
>> standalone computer,
[quoted text clipped - 29 lines]
> myDirectoryEntry.Invoke("setPassword", NewPwd);
> myDirectoryEntry.CommitChanges();
Alexey Smirnov - 06 Jun 2007 09:20 GMT
> May I know how to know the return code?
>
[quoted text clipped - 33 lines]
>
> - 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;
}
LamSoft - 06 Jun 2007 09:40 GMT
Thanks a lot
>> May I know how to know the return code?
>>
[quoted text clipped - 52 lines]
> return;
> }

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.