Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2632 connectés 

  FORUM HardWare.fr
  Systèmes & Réseaux Pro
  Infrastructures serveurs

  Un script pour desactiver les fonctionnalités d'Exchange

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Un script pour desactiver les fonctionnalités d'Exchange

n°55777
helios44
Posté le 08-07-2009 à 19:12:46  profilanswer
 

Bonjour,
 
J'ai hesité à poster mon message ds le forum VBS. Mais vu qu'en général les adeptes de la prog' sont moins avertis sur les "systemes"...
 
Aujourd'hui, j'ai du effectuer la manip suivante : desactiver les Services Mobiles & Protocoles pour chaque utilisateur.
Vu qu'il y en avait une centaine, ce ne fut pas trop trop long....enfin tout est relatif.
 
Je viens vers vous pour savoir si vous un script vbs serait possible pour eviter d'effectuer cette action à "la mano" ?
 
Merci

mood
Publicité
Posté le 08-07-2009 à 19:12:46  profilanswer
 

n°55778
Je@nb
Modérateur
Kindly give dime
Posté le 08-07-2009 à 20:28:55  profilanswer
 

exchange 2007 ?
 
Tu pipes ta liste d'utilisateur en powershell à la commande Set-CASMailbox http://technet.microsoft.com/fr-fr [...] 25264.aspx
 
Pour exchange 2003 va falloir faire mumuse avec l'attribut protocolSettings de l'object.
Tu as ce code de http://www.experts-exchange.com/Pr [...] 15593.html que tu peux utiliser

Code :
  1. '==================
  2. strInputFile = "Users_To_Disable_OWA.txt"
  3. Const intForReading = 1
  4. Set objFSO = CreateObject("Scripting.FileSystemObject" )
  5. Set objNetwork = CreateObject("WScript.Network" )
  6. Const ADS_PROPERTY_CLEAR = 1
  7. Const ADS_PROPERTY_UPDATE = 2
  8. Const ADS_PROPERTY_APPEND = 3
  9. Const ADS_PROPERTY_DELETE = 4
  10. Const conExInetOWAoff = "HTTP§0§1§§§§§§"
  11. Const conExInetOWAon = "HTTP§1§1§§§§§§"
  12. Set objInputFile = objFSO.OpenTextFile(strInputFile, intForReading, False)
  13. While Not objInputFile.AtEndOfStream
  14.       strLogin = objInputFile.ReadLine
  15.       strNTName = objNetwork.UserDomain & "\" & strLogin
  16.       strObjectType = "user" ' Can be "user", "group", or "computer"
  17.       strInputFormat = "NTLoginName" ' Can be "NTLoginName" or "DisplayName"
  18.       strUserDN = Get_DistinguishedName_From_AD(strNTName, strObjectType, strIntputFormat)
  19.    
  20.       If strUserDN <> "ERROR" Then
  21.             'MsgBox "adsPath of " & strNTName & ":" & VbCrLf & "LDAP://" & strUserDN
  22.             Set objUser = GetObject("LDAP://" & strUserDN)
  23.             On Error Resume Next
  24.             arrSettings = objUser.GetEx("protocolSettings" )
  25.             strSettings = ""
  26.             If Err.Number = 0 Then
  27.                   Err.Clear
  28.                   For Each protocolSettings In objSettings
  29.                         If Err.Number <> 0 Then Exit For
  30.                         If Left(protocolSettings, 4) <> "HTTP" Then
  31.                               ' Keep anything other than a HTTP Protocol
  32.                                     If strSettings = "" Then
  33.                                           strSettings = protocolSettings
  34.                                     Else
  35.                                           strSettings = strSettings & ";" & protocolSettings
  36.                                     End If
  37.                         End If
  38.                   Next
  39.                   Err.Clear
  40.                   On Error GoTo 0
  41.             Else
  42.                   Err.Clear
  43.                   On Error GoTo 0
  44.                   'MsgBox "Cannot retrieve protocolSettings"
  45.             End If
  46.             If strSettings = "" Then
  47.                   strSettings = conExInetOWAoff
  48.             Else
  49.                   strSettings = strSettings & ";" & conExInetOWAoff
  50.             End If
  51.                   On Error Resume Next
  52.                   ' Clear the settings before re-applying them
  53.                   objUser.PutEx ADS_PROPERTY_DELETE, "protocolSettings", 0
  54.                   objUser.SetInfo
  55.                   Err.Clear
  56.                   On Error GoTo 0
  57.             objUser.PutEx ADS_PROPERTY_APPEND, "protocolSettings", Split(strSettings, ";" )
  58.             objUser.SetInfo
  59.       Else
  60.             MsgBox "There was an error returning the DistinguishedName attribute of " & strNTName
  61.       End If
  62. Wend
  63. objInputFile.Close
  64. Set objInputFile = Nothing
  65. MsgBox "Done"
  66. Function Get_DistinguishedName_From_AD(strName, strObjectType, strInputFormat)
  67.       ' Source: http://www.rlmueller.net/NameTrans [...] eTranslate
  68.       ' Constants for the NameTranslate object.
  69.       ' INIT Method Parameters
  70.       ' To search a specific domain that is not the local one
  71.       Const ADS_NAME_INITTYPE_DOMAIN = 1 ' Use objTrans.Init ADS_NAME_INITTYPE_DOMAIN, "MyDomain.com"
  72.       ' To search a specific domain controller in the local domain
  73.       Const ADS_NAME_INITTYPE_SERVER = 2 ' Use objTrans.Init ADS_NAME_INITTYPE_SERVER, "MyServer"
  74.       ' To search through local domain - should be mainly used
  75.       Const ADS_NAME_INITTYPE_GC = 3 ' Use objTrans.Init ADS_NAME_INIITTYPE_GC, ""
  76.    
  77.       If LCase(strObjectType) = "computer" Then
  78.             If Right(strName, 1) <> "$" Then strName = strName & "$"
  79.       End If
  80.    
  81.       ' SET and GET Method Parameters
  82.       Const ADS_NAME_TYPE_1779 = 1
  83.       Const ADS_NAME_TYPE_CANONICAL = 2
  84.       Const ADS_NAME_TYPE_NT4 = 3
  85.       Const ADS_NAME_TYPE_DISPLAY = 4
  86.       Const ADS_NAME_TYPE_DOMAIN_SIMPLE = 5
  87.       Const ADS_NAME_TYPE_ENTERPRISE_SIMPLE = 6
  88.       Const ADS_NAME_TYPE_GUID = 7
  89.       Const ADS_NAME_TYPE_UNKNOWN = 8
  90.       Const ADS_NAME_TYPE_USER_PRINCIPAL_NAME = 9
  91.       Const ADS_NAME_TYPE_CANONICAL_EX = 10
  92.       Const ADS_NAME_TYPE_SERVICE_PRINCIPAL_NAME = 11
  93.       Const ADS_NAME_TYPE_SID_OR_SID_HISTORY_NAME = 12
  94.    
  95.       ' Use the NameTranslate object to convert the NT user name to the
  96.       ' Distinguished Name required for the LDAP provider.
  97.       Set objTrans = CreateObject("NameTranslate" )
  98.    
  99.       ' Initialize NameTranslate by locating the Global Catalog.
  100.       objTrans.Init ADS_NAME_INITTYPE_GC, ""
  101.       boolError = False
  102.       If LCase(strInputFormat) = "displayname" Then
  103.             ' Use the Set method to specify the Display Name of the object name.
  104.             On Error Resume Next
  105.             objTrans.Set ADS_NAME_TYPE_DISPLAY, strName
  106.             If Err.Number <> 0 Then boolError = True
  107.             On Error GoTo 0
  108.       Else ' assume it is the NTName
  109.             ' Use the Set method to specify the NT format of the object name.
  110.             On Error Resume Next
  111.             objTrans.Set ADS_NAME_TYPE_NT4, strName
  112.             If Err.Number <> 0 Then boolError = True
  113.             On Error GoTo 0
  114.       End If
  115.    
  116.       If boolError = False Then
  117.             ' Use the Get method to retrieve the RPC 1779 Distinguished Name.
  118.             strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
  119.       Else
  120.             strUserDN = "ERROR"
  121.       End If
  122.    
  123.       ' Escape any "/" characters with backslash escape character.
  124.       ' All other characters that need to be escaped will be escaped.
  125.       strUserDN = Replace(strUserDN, "/", "\/" )
  126.    
  127.       Get_DistinguishedName_From_AD = strUserDN
  128. End Function
  129. '==================

n°55783
helios44
Posté le 08-07-2009 à 21:53:02  profilanswer
 

Arfffffff ! Merci Jean.
 
Ben c'est pour du 2003... donc suis mal barré visiblement :-/

n°55784
Je@nb
Modérateur
Kindly give dime
Posté le 08-07-2009 à 22:01:46  profilanswer
 

ouais en 2007 tu fais ça en 1 ligne :D


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Systèmes & Réseaux Pro
  Infrastructures serveurs

  Un script pour desactiver les fonctionnalités d'Exchange

 

Sujets relatifs
Capacité Exchange 2003 - 2007 - 2010Gestion FAX Exchange 2003
exchange 2003Deploiment script pour installaiton logiciel .EXE problème droit admin
[Exchange 2003] Trop de mail dans la queueExchange 2010 beta en prod
Serveur exchange qui ne réceptionne pasInstaller Brightmail sur un SBS2003 avec déja NOD32 pour Exchange
[Exchange 2003] Processus Store.exe consomme beaucoup de CPUMessage marqué comme lu avec exchange (outlook 2003)
Plus de sujets relatifs à : Un script pour desactiver les fonctionnalités d'Exchange


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR