Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB Script Help with AD

Posted on 2008-10-09
3
Medium Priority
?
556 Views
Last Modified: 2013-12-24
Please can you help?
I got the following script from Microsoft. It is supposed to disable to OMA for accoutns in AD.

=================================================
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objUsers = GetObject("LDAP://CN=Users, " & objRootDSE.Get("defaultNamingContext"))
' set msExchOmaAdminWirelessEnable to 7 if currently null
For Each objUser In objUsers
            strname = objUser.Get("name")
'            WScript.Echo "name: " & strname
            strWirelessEnabled = objUser.Get("msExchOmaAdminWirelessEnable")
            If strWirelessEnabled = "" Then
                        objUser.Put "msExchOmaAdminWirelessEnable", "7"
                        objUser.setinfo
            End If
            strWirelessEnabled = objUser.Get("msExchOmaAdminWirelessEnable")          
Next
WScript.Echo "Mobile Services disabled for all users"
===========================================================

The OU where the accounts reside in my AD is:

Enter.local,   Users, London  (ou=London, ou=users, dc=Enter, dc=local)

When I run the script nothing changes. Maybe I havent entered the LDAP path correctly in the query? I noticed in the example from Microsoft that they entered the Users OU as CN=Users and I have also tried to change my script as such and still it doesn't work.

I have edited the script as below:

==================================================
On Error Resume Next
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objUsers = GetObject("LDAP://OU=London,OU=Users,DC=Enter,DC=local, " & objRootDSE.Get("defaultNamingContext"))
' set msExchOmaAdminWirelessEnable to 7 if currently null
For Each objUser In objUsers
            strname = objUser.Get("name")
'            WScript.Echo "name: " & strname
            strWirelessEnabled = objUser.Get("msExchOmaAdminWirelessEnable")
            If strWirelessEnabled = "" Then
                        objUser.Put "msExchOmaAdminWirelessEnable", "7"
                        objUser.setinfo
            End If
            strWirelessEnabled = objUser.Get("msExchOmaAdminWirelessEnable")          
Next
WScript.Echo "Mobile Services disabled for all users"

Based on the location of the OU, please can someone help me get this script working.

Thanks in advance.



0
Comment
Question by:naifyboy123
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 22684280
Hi, you cannot do:
Set objUsers = GetObject("LDAP://OU=London,OU=Users,DC=Enter,DC=local," & objRootDSE.Get("defaultNamingContext"))

as this would give you
OU=London,OU=Users,DC=Enter,DC=local,DC=Enter,DC=local

try either
Set objUsers = GetObject("LDAP://OU=London,OU=Users,DC=Enter,DC=local"

or
Set objUsers = GetObject("LDAP://OU=London,OU=Users," & objRootDSE.Get("defaultNamingContext"))

The objRootDSE.Get("defaultNamingContext") should automatically return your default naming context of DC=enter,DC=local

Regards,

Rob.
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22684519
Thanks for the grade.  I hope I was clear.  Do my comments make sense?

Regards,

Rob.
0
 

Author Comment

by:naifyboy123
ID: 22684533
yes they do thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

971 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