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
Solved

VB Script Help with AD

Posted on 2008-10-09
3
534 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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

856 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