Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Password Changing Script 2

Status
Not open for further replies.

ckugo

IS-IT--Management
Joined
Jan 6, 2004
Messages
165
Location
US
I am trying to change users passwords with the sample script that is in the microsoft script center. This one:


Set objUser = GetObject _
("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
objUser.ChangePassword "i5A2sj*!", "jl3R86df"

Everyone I run this I get an error that says:

A referral was sent to the server.
code: 8007202b
source: (null)

in the script, what do the two "dc"'s mean? I figured they stood for domain controller, but why is there two??

Any help is greatly apprecitated.
Thanks in Advance,

Chris
 
What you will want to do is have it loop for each entry you need to make.

OR

Change the way you are writing to the log file. You might want to do something like this:

text1 = "This is line 1"
text2 = "This is line 2"
report = text1 & vbCrLf & text2

ts.write report

This will add the following to the file:
This is line 1
This is line 2

 
Mark,

As far as looping goes, how would that work if different people ran this script at different times?? I understand what you said in your above post, but unfortunately I do not have the luxery of this being static text.

What basically needs to happen is that when a user changes their password this script will add that information below the most recent entry. Is there anyway to check for a blank line or to check if text has been written to a line?

Thanks,

Chris
 
Help me understand where you will be getting the data from. Maybe then I can answer your question better.

Do you now have a working ASP page that changes the passwords? If so, would you not just edit your ASP to have it write its information to the log file in append more? Each time someone visited that page and hit submitt it would post its data to the file.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Alright,
This thought started yesterday when I realized that it was time to change employee passwords. We have employees at different locations that connect to us through a vpn. When we change passwords I have to change them in many different places because we have to software that the users use that must be administered here. So I realize that I am stuck doing that, but I figured that they could at least change their own in AD.

Well, Microsoft made that easy in AD (change password at next login), but I would not be able to see what they changed their password to so I could change it on our locally administered software. So with the help of MisterNiceGuy, PHV , and you I am extremely close to getting this to work.

The script changes their password and logs it in a specified text file, but I cannot get it add the info at the bottom of the list. Look at this:

Example:
User1 changes password at 8:30a.m.
-Info gets written to txt file
User2 changes password at 11:00a.m.
-Info gets written to same text file

Log looks like:
User1 password
User2 password
etc....

That is exactly what I am trying to accomplish. But in my txt file the user2 line never gets written, it just replaces the user1 line.

The users themselves will be suppling the data. Then that data is supposed to get written to my log file.

I hope that helped and cleared up some foggy areas.

Thanks a lot,

Chris
 
Here, use this write file functino to manage the writing of information, and it should all work fine for you.
Put the Const line at the top of the script, then whenever you need to write a line to any file, simply pass all of the information to the function...i.e. ForWriting will overwrite the file, ForAppending will place text at bottom of file.

Const ForWriting = 2, ForAppending=8
Writefile "C:\Myfile.txt","The informatino I want added", Forappending

'This function manages writing information to a text file.
'The remarked out Constants set by the const key should be placed in the Variables section at the top of your script.
Function WriteFile(Filename,Text,WriteMethod)
'Define Constants for WriteFile Subroutine place these at top of script.
'Const ForWriting = 2, ForAppending=8
Dim fs, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(FileName, WriteMethod, True)
f.WriteLine Text
F.Close
End Function

'Note! the function will create the file, but it does not manage the folders, so the path you specify must exist. you can of course add code to handle any problem with a folder not existing, I just always pre-create my logging folders..
 
To avoid overwriting last log line, you can try to Open(for appending of course), Write and Close your line in one run.

Hope This Help
PH.
 
Thank You very much MisterNiceGuy. I did get that to do what I needed.

I would really like to thank everyone for all of their help again. Hope everyone has a good day.

Thanks,

Chris
 
Nicely done function MrNiceGuy!

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top