473,385 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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
Jun 6 '07 #1
4 4595
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Rich | last post by:
Hello, I have not been working with ASP for too long at this time and am not real familiar with a lot of things about ASP. I have searched for articles on the following question but not come up...
2
by: CJM | last post by:
I'm building an ASP app that uses Windows Authentication (IWA). I have an authentication routine that assesses if & how the user can use the application (see code snippet below). Users of a...
5
by: Andrei | last post by:
Hello, I posted yesterday the same problem, but now I want to be more specific about it. My intention is to create a windows service to process some Word documents. If I use CreateObject to...
3
by: Otie | last post by:
I found the following under the GetObject help notes and in the example for GetObject: "This example uses the GetObject function to get a reference to a specific Microsoft Excel worksheet...
1
by: Martyn Gwynne | last post by:
I am progressing with GetObject .. The following code will open and print a report. I enquired how to open, maximise WITHOUT printing by default and it was suggested that I look at further...
2
by: Randy Harris | last post by:
I'm going nuts trying to figure this out, sure hope someone can help. My application uses TransferSpreadsheet to insert data into an existing Excel spreadsheet (which works), then opens and...
17
by: ad | last post by:
We can use GetObject to load the instance of COM form file like: Dim CADObject As Object CADObject = GetObject("C:\CAD\SCHEMA.CAD") How can we implement the two statements above in CSharp?
3
by: perspolis | last post by:
Is there a method like GetObject in vb to get an instance of current object runnig??
3
by: ]-[aTc]-[ | last post by:
I'm trying to add users to active directing using asp.net forms. All the example on the web are for VB and using the VB method GetObject. Is there a C# sharp equivalent of GetObject or can...
1
by: joe | last post by:
We just moved a legacy asp application to a Win2003 server. The following line of code: set objUser = GetObject("WinNT://" & strDomain & "/" & strUserName & ",user") Raises the following...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.