Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vbs script almost works. Need help with a field name

Posted on 2011-02-17
4
Medium Priority
?
956 Views
Last Modified: 2012-05-11
I found this vbs script which is supposed to list all members in an Active Directory with their "Logon Script". If I comment out the line which is supposed to get the" Logon Script" value, the thing will run and generate the list of AD users.

If I uncomment that line, the thing runs, but fails at the line requesting the logon scirpt, with this

 "findNoLogonScriptUsers.vbs(56, 1) ADODB.Recordset: Item cannot be found in the collection corresponding to the requested name or ordinal."

A little research says either I spelled it wrong or I'm asking for a non-existant field.

What I want is the "logon script". I see this value in the AD gui, on the Profile tab. We use several scripts and I type only the name of the script in the gui, the OS knows the path

Here are 2 lines from the vbs script
=============================
strName = adoRecordset.Fields("sAMAccountName").Value

strScript = adoRecordset.Fields("scriptPath").value
=============================

The first apparently works, the second fails.

Is "scriptPath" the field name for the gui "Logog Script" field?

How would I get a list of AD field names? I mean pull it off my system. (Win Svr 2003, also using Exchange Server 2007)

I'm a noobie at this stuff, I'd appreciate any help. If this doesn't work, I can just get it manually
0
Comment
Question by:cgunix
[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
  • 2
4 Comments
 
LVL 21

Accepted Solution

by:
snusgubben earned 1000 total points
ID: 34919905
"scriptPath" is the correct name.

List of fields: http://fsuid.fsu.edu/admin/lib/WinADLDAPAttributes.html

Try this and see if it works. Edit the LDAP string to match your domain:


On Error Resume Next
Set objUser = GetObject _
  ("LDAP://cn=username,ou=your_ou,dc=domain,dc=com")
objUser.GetInfo
 
strScript = objUser.Get("scriptPath")
 
WScript.echo "scriptPath: " & strScript
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 1000 total points
ID: 34922549
Hi, scriptPath is the correct attribute, but you need to make sure your query is returning it as an available field.

This would mean your SELECT query needs to include it:
SELECT adsPath, samAccountName, scriptPath FROM .....

or your ADO filter needs to include it:
<LDAP://DC=domain,DC=com>;(&(objectClass=user);adsPath,samAccountName,scriptPath;subtree

Regards,

Rob.
0
 

Author Closing Comment

by:cgunix
ID: 34926821
Thanks for the help, but I couldn't make it work and can't spend more time on it - I just don't know enough about vbs syntax to follow your instructions. I made some progress, but it is my lack, not yours. I can do the task I need manually.

Thanks

LC
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34931025
If you post the part of your code that performs the query, we can test it and modify it for you.

Rob.
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

A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

636 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