ObjectName & legacyExchangeDN needs to be picked from a file and updated into the user.

Hi,

ObjectName & legacyExchangeDN needs to be picked from a file and updated into the user.
Can anyone help with a script and update the same if already exists do nothing
Record any failures.

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

markdmacCommented:
ObjectName isn't an AD attribute.  Please clarify.
0
bsharathAuthor Commented:
At the place of Objectname i have the user display name
0
markdmacCommented:
OK, so you want to search for display name, compare the LegacyExchangeDN and if different update it?

I would recommend that you use ADModify for this.  It will be fast and easy without the need for a script.
http://admodify.codeplex.com/releases/view/6065
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

bsharathAuthor Commented:
A lot os users have the names different when it comes to legacyDN. Any ways with specific users script
0
markdmacCommented:
You seem to have a lot of things like this to do so here is a function that is a bit more flexible for you.  This will let you specify what attribute you want to change and let's you provide multiple types of input to find the user such as displayName, sAMAccountName, cn, proxyAddresses etc.
AttributeToChange = "legacyExchangeDN"
WhatInfoIHave = "displayName"  'displayName or sAMAccountName or cn

UserName = "Bubba Gump"
newValue = "TSPExchange"

Set objUser = GetObject("LDAP://" & SearchDistinguishedName(UserName, WhatInfoIHave))
objUser.Put AttributeToChange, newValue
objUser.SetInfo



Public Function SearchDistinguishedName(ByVal vSAN, myInfo)
    Dim oRootDSE, oConnection, oCommand, oRecordSet
    Set oRootDSE = GetObject("LDAP://rootDSE")
    Set oConnection = CreateObject("ADODB.Connection")
    oConnection.Open "Provider=ADsDSOObject;"
    Set oCommand = CreateObject("ADODB.Command")
    oCommand.ActiveConnection = oConnection
    oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
        ">;(&(objectCategory=User)(" & myInfo & "=" & vSAN & "));distinguishedName;subtree"
    Set oRecordSet = oCommand.Execute
    On Error Resume Next
    SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
    On Error GoTo 0
    oConnection.Close
    Set oRecordSet = Nothing
    Set oCommand = Nothing
    Set oConnection = Nothing
    Set oRootDSE = Nothing
End Function

Open in new window

0
bsharathAuthor Commented:
Mark what should the input look as?
0
markdmacCommented:
And here is the same thing but reading from Excel.  You will want to have the header row named by the AD attributes.  Column 1 is the data that identifies the user, column 2 is the attribute you wish to update.

'==========================================================================
'
' NAME: ModifyUsers.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE  : 04/20/2010
' COPYRIGHT 2010 The Spider's Parlor, All Rights Reserved
'
'    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 MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'
' COMMENT: 
' Modifies users based on Excel spreadsheet information.
' Excel spreadsheet  formatting:
' Row 1 to have headings
' Column A (1) to have information to identify user account
' Column B (2) to have information to be changed 
'=====================================
On Error Resume Next
Set x = getobject(,"excel.application")
If Err.Number <> 0 Then
	MsgBox "Please open the source Excel spreadsheet and make sure there is only 1 Excel process running in Task Manager."
End If
r = 2

WhatInfoIHave = x.cells(1, 1).value  'displayName or sAMAccountName or cn if using proxyAddresses must be in form of smtp:user@company.com
AttributeToChange = x.cells(2, 1).value

Do until len(x.cells(r, 1).value) = 0
    UserName = x.cells(r, 1).value
    newValue  = x.cells(r, 2).value
	Set objUser = GetObject("LDAP://" & SearchDistinguishedName(UserName, WhatInfoIHave))
	objUser.Put AttributeToChange, newValue
	objUser.SetInfo
Loop


Public Function SearchDistinguishedName(ByVal vSAN, myInfo)
    Dim oRootDSE, oConnection, oCommand, oRecordSet
    Set oRootDSE = GetObject("LDAP://rootDSE")
    Set oConnection = CreateObject("ADODB.Connection")
    oConnection.Open "Provider=ADsDSOObject;"
    Set oCommand = CreateObject("ADODB.Command")
    oCommand.ActiveConnection = oConnection
    oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
        ">;(&(objectCategory=User)(" & myInfo & "=" & vSAN & "));distinguishedName;subtree"
    Set oRecordSet = oCommand.Execute
    On Error Resume Next
    SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
    On Error GoTo 0
    oConnection.Close
    Set oRecordSet = Nothing
    Set oCommand = Nothing
    Set oConnection = Nothing
    Set oRootDSE = Nothing
End Function

Open in new window

0
markdmacCommented:
Sharath, in the first example that is for 1 off updates and you would alter the first 4 lines of code with the data to change.

In the second you can use Excel as documented in the script.
0
bsharathAuthor Commented:
Mark sorry can we use txt files
Like
User name;Legacydn

i dont have office installed in the server
0
markdmacCommented:
Yes, I can rewrite it for that.  Have to deal with my regular job right now but will get to it soon.
0
bsharathAuthor Commented:
Ok thanks
0
markdmacCommented:
Here you go, this should do it.
'==========================================================================
'
' NAME: ModifyUsers.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE  : 04/20/2010
' COPYRIGHT 2010 The Spider's Parlor, All Rights Reserved
'
'    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 MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'
' COMMENT: 
' Modifies users based on CSV file. First line to have property information
' Example file:
' sAMAccountName,company
' bgump, bubbagump
' sgtdan,bubbagump
'=====================================

On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = CreateObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("userlist.txt")
'make an array from the data file
UserList = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
PropArray = Split(UserList(0),",")
WhatInfoIHave = PropArray(0)
AttributeToChange  = PropArray(1)

For x = 1 To UBound(UserList)
	ThisUser = Split(UserList(x),",")
	UserName = ThisUser(0)
	newValue  = ThisUser(1)
	Set objUser = GetObject("LDAP://" & SearchDistinguishedName(UserName, WhatInfoIHave))
	objUser.Put AttributeToChange, newValue
	objUser.SetInfo
Next


Public Function SearchDistinguishedName(ByVal vSAN, myInfo)
    Dim oRootDSE, oConnection, oCommand, oRecordSet
    Set oRootDSE = GetObject("LDAP://rootDSE")
    Set oConnection = CreateObject("ADODB.Connection")
    oConnection.Open "Provider=ADsDSOObject;"
    Set oCommand = CreateObject("ADODB.Command")
    oCommand.ActiveConnection = oConnection
    oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
        ">;(&(objectCategory=User)(" & myInfo & "=" & vSAN & "));distinguishedName;subtree"
    Set oRecordSet = oCommand.Execute
    On Error Resume Next
    SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
    On Error GoTo 0
    oConnection.Close
    Set oRecordSet = Nothing
    Set oCommand = Nothing
    Set oConnection = Nothing
    Set oRootDSE = Nothing
End Function

Open in new window

0
bsharathAuthor Commented:
Sorry mark what should the csv file look as
Displayname,Legacydn in my case
where should i mention the csv path
as in the code its as txt
0
markdmacCommented:
Example file info is in the comment of the script.  Change the file name on line 37, it is OK for the name to have the extension of CSV or TXT.
0
bsharathAuthor Commented:
Can i have the csv file headers as
Display name,legacyExchangeDN
0
markdmacCommented:
Yes
0
markdmacCommented:
correction to the above, you need to use the actual way it is listed in AD, so Display Name is actually displayName as one word.
0
markdmacCommented:
You can use ADSIEdit to get the attribute/property names.
0
bsharathAuthor Commented:
Still does not add.
in the txt file i have data as this
Displayname,legacyExchangeDN
Jain C C,/o=Group/ou=First Administrative Group/cn=Recipients/cn=JainCC
0
markdmacCommented:
Are you getting any errors?

Give this version a try, only difference is it will give a pop up with the distinguished name for the user to validate we are able to bind to the user object in AD.
'==========================================================================
'
' NAME: ModifyUsers.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE  : 04/20/2010
' COPYRIGHT 2010 The Spider's Parlor, All Rights Reserved
'
'    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 MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'
' COMMENT: 
' Modifies users based on CSV file. First line to have property information
' Example file:
' sAMAccountName,company
' bgump, bubbagump
' sgtdan,bubbagump
'=====================================

On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = CreateObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("userlist.txt")
'make an array from the data file
UserList = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
PropArray = Split(UserList(0),",")
WhatInfoIHave = PropArray(0)
AttributeToChange  = PropArray(1)

For x = 1 To UBound(UserList)
	ThisUser = Split(UserList(x),",")
	UserName = ThisUser(0)
	newValue  = ThisUser(1)
	
	UserLDAP = SearchDistinguishedName(UserName, WhatInfoIHave)
	MsgBox UserLDAP
	
	Set objUser = GetObject("LDAP://" & UserLDAP)
	objUser.Put AttributeToChange, newValue
	objUser.SetInfo
Next


Public Function SearchDistinguishedName(ByVal vSAN, myInfo)
    Dim oRootDSE, oConnection, oCommand, oRecordSet
    Set oRootDSE = GetObject("LDAP://rootDSE")
    Set oConnection = CreateObject("ADODB.Connection")
    oConnection.Open "Provider=ADsDSOObject;"
    Set oCommand = CreateObject("ADODB.Command")
    oCommand.ActiveConnection = oConnection
    oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
        ">;(&(objectCategory=User)(" & myInfo & "=" & vSAN & "));distinguishedName;subtree"
    Set oRecordSet = oCommand.Execute
    On Error Resume Next
    SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
    On Error GoTo 0
    oConnection.Close
    Set oRecordSet = Nothing
    Set oCommand = Nothing
    Set oConnection = Nothing
    Set oRootDSE = Nothing
End Function

Open in new window

0
bsharathAuthor Commented:
Mark i get no popup. The only change i do is the txt file name in the script
0
markdmacCommented:
Please post the first two lines of your text file.
0
bsharathAuthor Commented:
Displayname,legacyExchangeDN
Jain C C,/o=Group/ou=First Administrative Group/cn=Recipients/cn=JainCC
Shara t,/o=Group/ou=First Administrative Group/cn=Recipients/cn=sharat
0
markdmacCommented:
Hmm, don't know why it was failing passing that one argument but I was able to duplicate your problem.  This should do it.  
'==========================================================================
'
' NAME: ModifyUsers.vbs
'
' AUTHOR: Mark D. MacLachlan , The Spider's Parlor
' URL: http://www.thespidersparlor.com
' DATE  : 04/20/2010
' COPYRIGHT 2010 The Spider's Parlor, All Rights Reserved
'
'    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 MERCHANTABILITY AND/OR FITNESS FOR A
'    PARTICULAR PURPOSE.
'
'    IN NO EVENT SHALL THE SPIDER'S PARLOR AND/OR ITS RESPECTIVE SUPPLIERS 
'    BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
'    DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
'    WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
'    ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
'    OF THIS CODE OR INFORMATION.
'
'
' COMMENT: 
' Modifies users based on CSV file. First line to have property information
' Example file:
' sAMAccountName,company
' bgump, bubbagump
' sgtdan,bubbagump
'=====================================

On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set WSHShell = CreateObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("userlist.txt")
'make an array from the data file
UserList = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
PropArray = Split(UserList(0),",")
WhatInfoIHave = PropArray(0)
AttributeToChange  = PropArray(1)

For x = 1 To UBound(UserList)
        ThisUser = Split(UserList(x),",")
        UserName = ThisUser(0)
        newValue  = ThisUser(1)
        
        UserLDAP = SearchDistinguishedName(UserName)
        Set objUser = GetObject("LDAP://" & UserLDAP)
        objUser.Put AttributeToChange, newValue
        objUser.SetInfo
Next


Public Function SearchDistinguishedName(vSAN)
    Dim oRootDSE, oConnection, oCommand, oRecordSet
    Set oRootDSE = GetObject("LDAP://rootDSE")
    Set oConnection = CreateObject("ADODB.Connection")
    oConnection.Open "Provider=ADsDSOObject;"
    Set oCommand = CreateObject("ADODB.Command")
    oCommand.ActiveConnection = oConnection
    oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
        ">;(&(objectCategory=User)(displayName=" & vSAN & "));distinguishedName;subtree"
    Set oRecordSet = oCommand.Execute
    On Error Resume Next
    SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
    On Error GoTo 0
    oConnection.Close
    Set oRecordSet = Nothing
    Set oCommand = Nothing
    Set oConnection = Nothing
    Set oRootDSE = Nothing
End Function

Open in new window

0
bsharathAuthor Commented:
Still does not add...
Should i give the alias name or display name?
i have been giving the full name (Display name ) and it does not work
0
markdmacCommented:
If using the display name you will need to make sure it perfectly matches the AD.  Make sure you have the spaces the same etc.

Also, I don't have access to AD at the moment, can you validate that exchangeLegacyDN is just a string and not an array in AD?  If it takes multiple entries like an array then the code would need to be tweaked for that.
0
bsharathAuthor Commented:
Do you want me to check in ADSI or Bulk export about the exchangelegacydn or an array
0
markdmacCommented:
OK, so I validated that the legacyExchangeDN is just a string.  SO the above should be working.  Let's run a manual test to validate we are binding to the user OK.

When executed the below should reply with the distinguishedName of the user whose display name is "Shara t".  No changes have been made to the function, so let's validate that it can find your user before we try to figure out why it isn't setting the attribute you want.
UserName = "Shara t"
UserLDAP = SearchDistinguishedName(UserName)
WScript.Echo UserLDAP


Public Function SearchDistinguishedName(vSAN)
    Dim oRootDSE, oConnection, oCommand, oRecordSet
    Set oRootDSE = GetObject("LDAP://rootDSE")
    Set oConnection = CreateObject("ADODB.Connection")
    oConnection.Open "Provider=ADsDSOObject;"
    Set oCommand = CreateObject("ADODB.Command")
    oCommand.ActiveConnection = oConnection
    oCommand.CommandText = "<LDAP://" & oRootDSE.get("defaultNamingContext") & _
        ">;(&(objectCategory=User)(displayName=" & vSAN & "));distinguishedName;subtree"
    Set oRecordSet = oCommand.Execute
    On Error Resume Next
    SearchDistinguishedName = oRecordSet.Fields("DistinguishedName")
    On Error GoTo 0
    oConnection.Close
    Set oRecordSet = Nothing
    Set oCommand = Nothing
    Set oConnection = Nothing
    Set oRootDSE = Nothing
End Function

Open in new window

0
bsharathAuthor Commented:
I get this

---------------------------
Windows Script Host
---------------------------
CN=Shara t,OU=IT_Migrated,DC=Dev,DC=Group,DC=co,DC=uk
---------------------------
OK  
---------------------------
0
markdmacCommented:
OK, so it is successfully finding your user.  So now let's just validate the writing to AD part.
newValue = "/o=Group/ou=First Administrative Group/cn=Recipients/cn=sharat"
 UserLDAP = "CN=Shara t,OU=IT_Migrated,DC=Dev,DC=Group,DC=co,DC=uk"
 Set objUser = GetObject("LDAP://" & UserLDAP)
 objUser.Put AttributeToChange, newValue
 objUser.SetInfo

Open in new window

0
markdmacCommented:
Sorry forgot to change that one variable to be hard coded
newValue = "/o=Group/ou=First Administrative Group/cn=Recipients/cn=sharat"
 UserLDAP = "CN=Shara t,OU=IT_Migrated,DC=Dev,DC=Group,DC=co,DC=uk"
 Set objUser = GetObject("LDAP://" & UserLDAP)
 objUser.Put "legacyExchangeDN", newValue
 objUser.SetInfo

Open in new window

0
bsharathAuthor Commented:
I tried both and it did not add the x500
0
markdmacCommented:
If you are trying to add an X500 entry then should that note be added in ProxyAddresses in the form of "X500:/o=Group/ou=First Administrative Group/cn=Recipients/cn=sharat"
0
bsharathAuthor Commented:
As this
Capture.JPG
0
markdmacCommented:
Hmm I don't have that in my AD.  Is it a custom attribute?
0
bsharathAuthor Commented:
Its in Exchange 2007
0
markdmacCommented:
My lab machine is running on Exchange 2007 and I don't have that.  You sure it wasn't added to your schema?  My lab system is a VHD direct from Microsoft.
0
bsharathAuthor Commented:
In the email tab of the user i have
Add button when clicked i have custome. thats where i add this
0
markdmacCommented:
So as a custom entry it is not a default.  ;-)
When you say the email tab please explain.  In which tool are you working?  ADUC or Exchange Management Console?  We are still talking Exchange 2007 or Exchange 2003?  When you say Email tab do you mean Email Addresses?  

What I suspect is you are adding an x500 to the Email Addresses (which is Proxy Addresses).  If that is the case then this script would need to be changed because that is not a string but is an array we need to append to.  You also have to preface the entry with "X500:"

From the originally posted code, replace this line:
      objUser.Put AttributeToChange, newValue
With the below
objUser.PutEx 3, "proxyAddresses", Array("X500:" & newValue)

Open in new window

0
bsharathAuthor Commented:
Mark i tried the change but did not work
i am talking about exchange 2007
Exchange Console
Please see screenshot
Capture.JPG
0
markdmacCommented:
OK, so that confirms it is in fact the proxyAddresses you need to modify.  The provided code should do the trick but go ahead and validate you can do it with script with this simple example.

If the below doesn't work you have a permissions issue or have provided incorrect path information to the user object.
Const ADS_Property_Append = 3
newValue = "/o=Group/ou=First Administrative Group/cn=Recipients/cn=sharat"
UserLDAP = "CN=Shara t,OU=IT_Migrated,DC=Dev,DC=Group,DC=co,DC=uk"
Set objUser = GetObject("LDAP://" & UserLDAP)
objUser.PutEx ADS_Property_Append, "proxyAddresses", "X500:" & newValue
objUser.SetInfo

Open in new window

0
bsharathAuthor Commented:
I get this
C:\test.vbs(4, 1) (null): A referral was returned from the server.
0
markdmacCommented:
Verify DNS, the script is unable to bind to the user object.  From the distinguishedName information you provided it would appear the domain name uses a public domain instead of a .local?  Is that correct?  The domain is Dev.Group.Co.UK?

Make sure that the PC that the script it running on is a member of the same domain as the user object you are trying to connect to.
0
bsharathAuthor Commented:
Actually i changed the name to post it here
Any way i missed the .local in my original code as well. When  i set the path right and run i get this

C:\>test
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

C:\test.vbs(5, 1) Active Directory: Unspecified error
0
markdmacCommented:
OK so let's try to get a better error message so we know what is wrong.
On Error Resume Next
Const ADS_Property_Append = 3
newValue = "/o=Group/ou=First Administrative Group/cn=Recipients/cn=sharat"
UserLDAP = "CN=Shara t,OU=IT_Migrated,DC=Dev,DC=Group,DC=co,DC=uk"
Set objUser = GetObject("LDAP://" & UserLDAP)
objUser.PutEx ADS_Property_Append, "proxyAddresses", "X500:" & newValue
objUser.SetInfo
If Err.Number <> 0 Then
   Wscript.echo Err.Number & "  " & Err.Description
End If

Open in new window

0
bsharathAuthor Commented:
I get this

-2147467259  Unspecified error
0
markdmacCommented:
Is the property set or not?
0
bsharathAuthor Commented:
Its not set
0
markdmacCommented:
For anyone following this thread, we worked on this live together and determined a few issues.  The most pressing was that in the above code we were trying to add X500 which is a primary address.  We had to add a secondary x500 (note the lower case x).  We also noted that the script worked great when there was not already an x500 entry, but it did nothing when one already existed.  Did not isolate the reason for that but Sharath is going to try to use ADModify to update these users now.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.