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

x
?
Solved

Script that can get to a user's protocolsettings and remove the mapi from it. I want to query every user in a OU and do this one after the other

Posted on 2010-11-16
2
Medium Priority
?
596 Views
Last Modified: 2012-05-10
Hi,

Script that can get to a user's protocolsettings and remove the mapi from it. I want to query every user in a OU and do this one after the other

Record the success or failure into a file.

Exchange 2003 & Windows 2003 Domain

Can anyone help please

regards
Sharath
Capture.JPG
0
Comment
Question by:bsharath
[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
2 Comments
 
LVL 8

Accepted Solution

by:
GundogTrainer earned 2000 total points
ID: 34144753
I have edited one of my scripts that I use to remove other properties to provide a starting point.

Hopefully you will get the idea of what its trying to do:
first part is to enumerate all the objects in the specified OU.
 the for each of these objects check if they have a "MAPI" protocol and if so remove it.
if you update line 10 for your DN name \ ldap path to OU it will just display the objects it will be checking.
I would suggest you use it to pick on one and test it by uncommenting line 4 & 5 etc.

Just ensure you test it first !!!!

SySConUN=""
SySConPW=""

'x=getdata("LDAP://Servername/CN=test account,ou=Users,DC=test,dc=local")
'wscript.quit

 Set objAdRootDSE = GetObject("LDAP://RootDSE")
 varDefaultNC = objAdRootDSE.Get("defaultNamingContext")

 SQLSYSTEMS = "SELECT adspath,cn, distinguishedName,displayname FROM 'LDAP://Servername/ou=user accounts," & varDefaultNC & "'"
 Set SySConn = CreateObject("ADODB.Connection")
 Set SysCommand = CreateObject("ADODB.Command")
 SySConn.Provider = "ADSDSOObject"
 Sysconn.Open "Active Directory Provider" ,SySConUN,SySConPW
 set SysCommand.Activeconnection = SysConn
 SysCommand.commandtext = SQLSYSTEMS
 SYSCommand.Properties("Page Size")=100
 'wscript.echo SQLSYSTEMS
 Set SySrs = SysCommand.Execute

  if SySrs.recordcount >0 then

    MailboxesinIT6=SySrs.recordcount
    Do While Not SySrs.EOF Or SySrs.BOF
    ' x=getdata(SySrs.fields("adspath")
    wscript.echo SySrs.fields("adspath") ' diable this line once its working!
    SySrs.MoveNext
    Loop

  end if
 SySConn.close
 Set SySConn=nothing


function getdata(byref userDN)
 Set RefUser= getobject(UserDN)
 x= Refuser.protocolSettings
 newcnt=0
 Userupdate=0
 dim y()

 if isarray(x) then
  for pass= 0 to ubound(x)
    if left(x(pass),4)<>"MAPI" then 
      redim preserve y(newcnt)
      y(newcnt)=x(pass)
      newcnt=newcnt+1
    else
     'MAPI found so we will update the record
     Userupdate=1
    end if
  next
  if Update=1 then 
    Refuser.putex 2,"protocolSettings",y
    refuser.setinfo
    wscript.echo UserDN & chr(9) & "MAPI Removed"
   else
    wscript.echo UserDN & chr(9) & "Ignored"
   end if   
  'for t=0 to ubound(y)
  'wscript.echo y(t)
  'next
  else
  'not an array code here if needed.
 end if
end function

Open in new window

0
 
LVL 8

Expert Comment

by:GundogTrainer
ID: 34145417
oh to record it to a file execute it with the command cscript.exe //nologo script.vbs >>log.txt
0

Featured Post

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

721 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