Saturday, February 11, 2012

Delete all contacts & contact groups from a Lync-2010 User

To delete all contacts & contacts groups from particular lync user, first we have to find out the internal ID of the lync user.
Through “rtc” SQL server database of lync, we can easily find it from “Resource” table.
Eg: Lync user Sign-In Address : bashar@sample.com
Open a new query window from the SQL server management studio and execute the following query
select ResourceId from Resource where UserAtHost=’bashar@sample.com’
You can see the internal ID of the user as query result. Eg:’395’

To delete all the contacts of the user with id 395, execute the below query:
delete FROM [rtc].[dbo].Contact where OwnerId=395
To delete all the contact group association of the user with id 395, execute the below query:
delete  FROM [rtc].[dbo].[ContactGroupAssoc]  where OwnerId=395
To delete all the contact groups of the user with id 395, execute the below query:
delete  FROM [rtc].[dbo].ContactGroup  where OwnerId=395

1 comment:

  1. Hi,
    we have 1600 users. How to run these queries to delete contacts for all users?

    ReplyDelete