Quantcast
Channel: TechCenter
Viewing all articles
Browse latest Browse all 2350

How to remove X400 address

$
0
0
Revision 1 posted to Active Roles Script Center by DELL-Tatiana G on 2/24/2014 6:58:49 AM

Back to Exchange management

DESCRIPTION

This script sample demonstrates how to remove X400 address from user object's proxy addresses


Note This code may use functions from the ARS Script Policy Best Practices. Please, follow the link to obtain instructions and code for those functions.


SCRIPT

 

'*********************************************************************************

' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,

' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED

' WARRANTIES OF MERCHANTBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

'

' IF YOU WANT THIS FUNCTIONALITY TO BE CONDITIONALLY SUPPORTED,

' PLEASE CONTACT QUEST PROFESSIONAL SERVICES.

'*********************************************************************************

'

' This code is published on the ActiveRoles Script Center:

' http://communities.quest.com/docs/DOC-9991

'

' This code may use functions from the ARS Script Policy Best Practices:

' http://communities.quest.com/docs/DOC-10016

'

' Please, follow the link to obtain instructions and code for those functions.

'*********************************************************************************

Option Expicit

Call RemoveX400Address("CN=John Smith,OU=Sales,DC=foo,DC=com")

'-- constants

Const ADS_PROPERTY_CLEAR = 1

Const ADS_PROPERTY_UPDATE = 2

'-- routines

Sub RemoveX400Address (ByVal strUserDN)

Dim objUser, arrProxyAddresses, arrProxyAddresses2, strProxyAddress

'-- bind to user object

'-- change EMDS:// to LDAP:// to work without Quest ActiveRoles Server

objUser = GetObject("EMDS://" & strUserDN)

Call objUser.GetInfoEx(Array("proxyAddresses"), 0)

'-- try to get proxyAddresses

On Error Resume Next

arrProxyAddresses = objUser.GetEx("proxyAddresses")

On Error Goto 0

'-- exit if no values for proxyAddresses are found

If (IsEmpty(arrProxyAddresses)) Then Exit Sub

'-- filter for unwilling values

arrProxyAddresses2 = Array()

For Each strProxyAddress in arrProxyAddresses

If (Not StringStartsWith(strProxyAddrress, "X400:")) Then

Call AddValueToArray(arrProxyAddresses2, strProxyAddrress)

End If

Next

'-- update proxyAddresses

If (UBound(arrProxyAddresses2) = -1) Then

Call objUser.PutEx ADS_PROPERTY_CLEAR, "proxyAddresses", Empty

Else

Call objUser.PutEx ADS_PROPERTY_UPDATE, "proxyAddresses", arrProxyAddresses2

End If

Call objUser.SetInfo()

End Sub ' RemoveX400Address

'-- helping routines

Sub AddValueToArray(ByRef Arr, ByVal Val)

ReDim Preserve Arr (UBound(Arr)+1)

Arr(UBound(Arr)) = Val

End Sub ' AddValueToArray

Function StringStartsWith(ByVal strWhere, ByVal strWhat)

StringStartsWith = (Left(strWhere, Len(strWhat)) = strWhat)

End Function ' StringStartsWith

'***** END OF CODE ***************************************************************

COMPATIBILITY

Script compatible with the following version(s): <Not specified>

Back to Exchange management


Viewing all articles
Browse latest Browse all 2350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>