Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB Script Help with AD

Posted on 2008-10-09
3
Medium Priority
?
552 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
[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
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Lotus Notes has been used since a very long time as an e-mail client and is very popular because of it's unmatched security. In this article we are going to learn about  RRV Bucket corruption and understand various methods to Fix "RRV Bucket Corrupt…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

715 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