Solved

WSCRIPT / ADSI / Password Reset

Posted on 2006-10-29
6
1,372 Views
Last Modified: 2008-01-09
Hi,

I am looking for some guidance, I currently have the following script that I want to use to bind to an AD DC.  This will then reset the password for the specified, account.  The reason the credentials are being specified is because the script will be used to access many other domains as well as the one the server is a member of.

However myscript always fails on the objUser.SetPassword line, with an error of Access Denied.  Now the user being used to bind to AD does have the privilges to change this, as it is an enterprise admin, and doing so thru ADUC works fine.

I am guessing that my binding to AD is either unsuccessful, and resulting in the use of the locally logged on credentials, or it is not binding at all...

However if I replace the objUser.SetPassword (strNewPasswd) with   "Wscript.Echo objUser.AdsPath"  the script promptly returns the DN of the account in question...

Any ideas??

Cheers,
Tony


-----------
Set objRootDSE = GetObject("LDAP://servername.domain.suffix/RootDSE")


####
Credentials Used to Bind to AD with
####
strPath = "LDAP://CN=UserName,OU=CompanyUsers,DC=domain,DC=suffix"
strUser = "username@domain.suffix"
strPasswd = "Password1"



####
Account I want to have the password reset
####
strUserDN = " CN=Username2, OU=CompanyUsers, DC=domain,DC=suffix"
strNewPasswd = "Password!"

Set objUser = GetObject("LDAP://" & strUserDN)
objUser.GetInfo
objUser.SetPassword (strNewPasswd)
objUser.SetInfo


------------
0
Comment
Question by:ihotdesk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 3

Author Comment

by:ihotdesk
ID: 17830313
Please also note that the lines beginning with  #### and the comments inbetween are not present inthe script and are only a means of highlighting text for the purposes of this question

Cheers,
Tony
0
 
LVL 4

Expert Comment

by:KPCarl
ID: 17830494
Looks like you aren't setting the credentials...

Try:

Set objDSO = GetObject("LDAP:")
Set objUser = objDSO.OpenDSObject(strPath, strUser, strPasswd,0}
     
0
 
LVL 4

Expert Comment

by:KPCarl
ID: 17830501
Correction:

Set objDSO = GetObject("LDAP:")
Set objUser = objDSO.OpenDSObject(strPath, strUser, strPasswd,0)
0
 
LVL 4

Accepted Solution

by:
KPCarl earned 500 total points
ID: 17830533
Use this if you want to encrypt traffic: between your computer and the domain:


Const ADS_SECURE_AUTHENTICATION = 1
Const ADS_USE_ENCRYPTION = 2


Set objDSO = GetObject("LDAP:")
Set objUser = objDSO.OpenDSObject (strPath, strUser, strPasswd, _
ADS_USE_ENCRYPTION OR ADS_SECURE_AUTHENTICATION)

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
many domain users as service accounts - not documented 2 85
What is this Task? 4 147
ESEUTIL Stopped Working Need a new copy for 2003 Exchange. 11 62
Drive mapping problem 7 42
I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
On July 14th 2015, Windows Server 2003 will become End of Support, leaving hundreds of thousands of servers around the world that still run this 12 year old operating system vulnerable and potentially out of compliance in many organisations around t…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question