I have written a script that will change a password from the sources in
MS Scripts resource. This is the actual code:

strUserDN = "cn=testusera,ou=Admins,dc=testdc01,dc=domain,dc=com"
strNewPasswd = "pass123456"

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


however when I run it, the following error occurs " A referral was
returned from the server."

I read some posts from here and it said add the DC's name to the UserDN
path testdc01, however it still doesn't work. The original script did't
have that and it still gave the same error........

Any on please help....

Re: Script to change password via objUser.setpasswd by Steve

Steve
Mon Jan 23 06:10:00 CST 2006

Z wrote:

>I have written a script that will change a password from the sources in
>MS Scripts resource. This is the actual code:
>
>strUserDN = "cn=testusera,ou=Admins,dc=testdc01,dc=domain,dc=com"
>strNewPasswd = "pass123456"
>
>'Set objUser = GetObject("LDAP://" & strUserDN)
>objUser.SetPassword(strNewPasswd)
>
>
>however when I run it, the following error occurs " A referral was
>returned from the server."
>
>I read some posts from here and it said add the DC's name to the UserDN
>path testdc01, however it still doesn't work. The original script did't
>have that and it still gave the same error........
>
>Any on please help....

You changed the LDAP query to refer to your own AD domain naming, right?
You didn't leave it as "dc=domain,dc=com" ?

domain.com is a fictitious AD domain name, with a fictitious Admins OU.

You can see the full string for any of your real user accounts with ADSI
Edit, and look at the Properties of any user account.

--
Steve Foster [SBS MVP]
---------------------------------------
MVPs do not work for Microsoft. Please reply only to the newsgroups.

Re: Script to change password via objUser.setpasswd by Z

Z
Mon Jan 23 12:08:07 CST 2006

Steve,

Yes I did replace the LDAP query name with our domains name however it
stll doesn't seem to work....

Any other ideas...


Thanks


Re: Script to change password via objUser.setpasswd by Jerold

Jerold
Mon Jan 23 14:13:30 CST 2006


Works fine if you remove the ' from infront of Set objUser.

On 23 Jan 2006 01:19:48 -0800, "Z" <momo2804@gmail.com> wrote:

>I have written a script that will change a password from the sources in
>MS Scripts resource. This is the actual code:
>
>strUserDN = "cn=testusera,ou=Admins,dc=testdc01,dc=domain,dc=com"
>strNewPasswd = "pass123456"
>
>'Set objUser = GetObject("LDAP://" & strUserDN)
>objUser.SetPassword(strNewPasswd)
>
>
>however when I run it, the following error occurs " A referral was
>returned from the server."
>
>I read some posts from here and it said add the DC's name to the UserDN
>path testdc01, however it still doesn't work. The original script did't
>have that and it still gave the same error........
>
>Any on please help....

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com

Re: Script to change password via objUser.setpasswd by Z

Z
Mon Jan 23 18:59:43 CST 2006

actually in my actual script the ' is removed............. it must
have been an error when i pasted the script.......

the actual code is


strUserDN = "cn=testusera,ou=Admins,dc=testdc01,dc=domain,dc=com"
strNewPasswd = "pass123456"


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

but it still gives the same error

A referral was returned from the server.

Exit code: 0 , 0000h


any ideas?


Re: Script to change password via objUser.setpasswd by axtens

axtens
Mon Jan 23 21:04:20 CST 2006

I use WinNT rather than LDAP for this particular issue as below:

Set oUser = GetObject( "WinNT://" & sDomain & "/" & sUserName )
oUser.SetPassword( "Monday1" )

If MsgBox( "Force " & sFullName & " to enter new password at login?", _
vbYesNo, "Monday1.plug" ) = vbYes Then
oUser.Put "PasswordExpired", CLng( 1 )
End If

The second part expires the password so that the user is forced to
supply a new one when they logon.

HTH,
Bruce.


Re: Script to change password via objUser.setpasswd by Yannick

Yannick
Tue Jan 24 11:18:57 CST 2006

Hello,

You must first read the properties of the object, before modifying it, and
then putting it in Active directory.
It's like a local cache you must fill, then modifying (localy) and finally
putting in AD modified.

Try this :
_________________________________________________________
strUserDN = "cn=testusera,ou=Admins,dc=testdc01,dc=domain,dc=com"
strNewPasswd = "pass123456"

' Binds object to modify
Set objUser = GetObject("LDAP://" & strUserDN)

' Fills the cache with object properties
objUser.GetInfo

' Modifying local cached data
objUser.SetPassword(strNewPasswd)

' passes modified data to active directory
objUser.SetInfo
_________________________________________________________

Note than I can't test it (I'm at home, and don't have test AD), so it may
be some syntax errors !

Hope it could help you.

Yannick SCHAPPLER
France


"Z" <momo2804@gmail.com> a écrit dans le message de news:
1138064383.251241.56280@z14g2000cwz.googlegroups.com...
> actually in my actual script the ' is removed............. it must
> have been an error when i pasted the script.......
>
> the actual code is
>
>
> strUserDN = "cn=testusera,ou=Admins,dc=testdc01,dc=domain,dc=com"
> strNewPasswd = "pass123456"
>
>
> Set objUser = GetObject("LDAP://" & strUserDN)
> objUser.SetPassword(strNewPasswd)
>
> but it still gives the same error
>
> A referral was returned from the server.
>
> Exit code: 0 , 0000h
>
>
> any ideas?
>



Re: Script to change password via objUser.setpasswd by Z

Z
Tue Jan 24 22:16:51 CST 2006

Ok I managed to get that working................. but another thing I'm
trying is to get the UserDN, I've found two scripts which both don't
seem to work or I'm coding something wrong here..........



Dim obj
Const ADS_NAME_INITYPE_DOMAIN = 1
Const ADS_NAME_INITTYPE_SERVER = 2
Const ADS_NAME_INITTYPE_GC = 3

Const ADS_NAME_TYPE_1779 = 1
Const ADS_NAME_TYPE_NT4 = 3

samAccountName = gtsadmin

Set obj = CreateObject("NameTranslate")
obj.Init ADS_NAME_INITTYPE_GC, ""
obj.Set ADS_NAME_TYPE_NT4, samAccountName
result = obj.Get(ADS_NAME_TYPE_1779)
WScript.Echo result

and this one doesn't work either...............


Dim nto
const ADS_NAME_INITTYPE_SERVER = 2
const ADS_NAME_TYPE_1779 = 1
const ADS_NAME_TYPE_NT4 = 3

Server = "hk-labdc1"
user = "administrator"
dom = "GC"
passwd = "pass1234"

Set nto = Server.CreateObject("NameTranslate")
nto.InitEx ADS_NAME_INITTYPE_SERVER, server, user, dom, passwd
nto.Set ADS_NAME_TYPE_1779, dn
result = nto.Get(ADS_NAME_TYPE_GUID)

wscript.echo result



thanks in advance..............


Re: Script to change password via objUser.setpasswd by Yannick

Yannick
Wed Jan 25 11:57:59 CST 2006

Sorry, I cant't help you about that... I don't understand it !!!

What should it do, and what do you want to do ?

Yannick SCHAPPLER
France



"Z" <momo2804@gmail.com> a écrit dans le message de news:
1138162611.158923.293640@g44g2000cwa.googlegroups.com...
> Ok I managed to get that working................. but another thing I'm
> trying is to get the UserDN, I've found two scripts which both don't
> seem to work or I'm coding something wrong here..........
>
>
>
> Dim obj
> Const ADS_NAME_INITYPE_DOMAIN = 1
> Const ADS_NAME_INITTYPE_SERVER = 2
> Const ADS_NAME_INITTYPE_GC = 3
>
> Const ADS_NAME_TYPE_1779 = 1
> Const ADS_NAME_TYPE_NT4 = 3
>
> samAccountName = gtsadmin
>
> Set obj = CreateObject("NameTranslate")
> obj.Init ADS_NAME_INITTYPE_GC, ""
> obj.Set ADS_NAME_TYPE_NT4, samAccountName
> result = obj.Get(ADS_NAME_TYPE_1779)
> WScript.Echo result
>
> and this one doesn't work either...............
>
>
> Dim nto
> const ADS_NAME_INITTYPE_SERVER = 2
> const ADS_NAME_TYPE_1779 = 1
> const ADS_NAME_TYPE_NT4 = 3
>
> Server = "hk-labdc1"
> user = "administrator"
> dom = "GC"
> passwd = "pass1234"
>
> Set nto = Server.CreateObject("NameTranslate")
> nto.InitEx ADS_NAME_INITTYPE_SERVER, server, user, dom, passwd
> nto.Set ADS_NAME_TYPE_1779, dn
> result = nto.Get(ADS_NAME_TYPE_GUID)
>
> wscript.echo result
>
>
>
> thanks in advance..............
>