WNottsC
asked on
VBscript to Hide from exchange list
I have a vbscript that works perfectly well at disabling an account and removing all group membership apart from the Primary Group.
The subroutine is shown below. If however I uncomment the two lines for hiding from the exchange list it comes up with an error code -2147463153
would you be able to tell me what is wrong
'------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
' This subroutine Disables users.
'------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---
Sub DisableUser
'************************* ********** ********** ********** ********** ********** ******
' Disable the User Account
'************************* ********** ********** ********** ********** ********** ******
objUser.AccountDisabled = True
objUser.SetInfo
On Error Resume next
objUser.Put "msExchHideFromAddressList s", True
objUser.SetInfo
If Err.Number = 0 Then
Report "User hidden successfully."
Else
Report Err.number
Report Err.Desciption
Report "Sorry something went wrong, check user name."
End If
' Enumerate all direct group memberships (except the "primary" group).
For Each objGroup In objUser.Groups
' Remove the user from the group.
objGroup.Remove(objUser.Ad sPath)
Next
End Sub
The subroutine is shown below. If however I uncomment the two lines for hiding from the exchange list it comes up with an error code -2147463153
would you be able to tell me what is wrong
'-------------------------
' This subroutine Disables users.
'-------------------------
Sub DisableUser
'*************************
' Disable the User Account
'*************************
objUser.AccountDisabled = True
objUser.SetInfo
On Error Resume next
objUser.Put "msExchHideFromAddressList
objUser.SetInfo
If Err.Number = 0 Then
Report "User hidden successfully."
Else
Report Err.number
Report Err.Desciption
Report "Sorry something went wrong, check user name."
End If
' Enumerate all direct group memberships (except the "primary" group).
For Each objGroup In objUser.Groups
' Remove the user from the group.
objGroup.Remove(objUser.Ad
Next
End Sub
Hi
The code mentioned by you for hiding works and no changes required.
objUser.Put "msExchHideFromAddressList s", True
objuser.setinfo
can you give err.clear at beginning of subroutine and try
The code mentioned by you for hiding works and no changes required.
objUser.Put "msExchHideFromAddressList
objuser.setinfo
can you give err.clear at beginning of subroutine and try
ASKER
I still get the -2147463153 error
Can you give the description of the error, can you also check if the hide value is being set to true.
Hi
Does the user whom you are trying to hide have exchange attributes, is the user mail enabled?
We cannot hide user if he is not mail enabled.
I had tested the script against mail enabled user and it worked fine, for non mail enabled user it threw -2147463153 error.
Does the user whom you are trying to hide have exchange attributes, is the user mail enabled?
We cannot hide user if he is not mail enabled.
I had tested the script against mail enabled user and it worked fine, for non mail enabled user it threw -2147463153 error.
you could try this:
const ADS_PROPERTY_UPDATE = 2
objUser.PutEx ADS_PROPERTY_UPDATE, "msExchHideFromAddressList s", True
objUser.SetInfo
or maybe this
objUser.Get("msExchHideFro mAddressLi sts")
objUser.Put "msExchHideFromAddressList s", True
const ADS_PROPERTY_UPDATE = 2
objUser.PutEx ADS_PROPERTY_UPDATE, "msExchHideFromAddressList
objUser.SetInfo
or maybe this
objUser.Get("msExchHideFro
objUser.Put "msExchHideFromAddressList
ASKER
this error does not bring back a description, it does have exchange attributes but with exchange 2007 you no longer have tabs on the AD user account for the exchange information. Not sure if exchange 2007 is the reason this error is coming up.
Tried it again on a different account and it is still having the same issue. even using
objUser.Get("msExchHideFro mAddressLi sts")
objUser.Put "msExchHideFromAddressList s", True
objUser.SetInfo
Tried it again on a different account and it is still having the same issue. even using
objUser.Get("msExchHideFro
objUser.Put "msExchHideFromAddressList
objUser.SetInfo
ASKER
we are using this code for connecting to the object could this be the issue. However it works for disabling the account and removing group membership just not the exchange list
Set objUser = GetObject("WinNT:// { NETBIOS Domain name } " & "/" & strstaffID)
Set objUser = GetObject("WinNT:// { NETBIOS Domain name } " & "/" & strstaffID)
Can you try to fetch the information and display the present value, using the objUser.Get("msExchHideFro mAddressLi sts") to check the error it is throwing. Try to only get the value, not set the value.
ASKER
this gives us a 2147463155 error
ASKER
sorry and the description for that error is The directory property cannot be found in the cache
can you use adsiedit to check if the property exists for the user.
ASKER
the property exists but it is <not set>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
objUser.Put "msExchHideFromAddressList
to
objUser.msExchHideFromAddr
and get the following error
438 Object doesn't support this property or method