5

We are creating a custom application trying to get the contact list from address book.

The list of addressbooks is accessed using StaticAddressBook.GetList, it provides the list of all the addressbooks the usercontext can access. But the user might not have read permissions for some addressbooks.

Help would be appreciated if someone could guide me the way to figure out if the trustee is permitted to read the addressbook contacts.

2 Answers 2

2

I have done the below code and got the solution for my issue, if it helps someone else:

//UserContext.Current cant be used to getlist as there is a 
        foreach (StaticAddressBook addressBook in StaticAddressBook.GetList(new UserContext(), new TcmUri(System.Configuration.ConfigurationManager.AppSettings["PublicationURI"])))
        {
            try
            {
                dictAddressBooks.Add(addressBook.Title, addressBook.Id.ToString());

                //to confirm if the user have read permission to the addressbook
                //if the user doesnt have permission then exception.
                int count = addressBook.GetContacts().Count();
            }
            catch
            {
                //Removing the address book if the user gets error on accessing the contacts
                dictAddressBooks.Remove(addressBook.Title);
            }

        }
        return dictAddressBooks;

The above code is actually a work around for the solution., and this is working fine.

If there is any other implementation in the cms libraries please update.

1

I do not suspect that this is an issue related to rights. Please refer Peter's blog HERE and a related question HERE.

I hope it helps.

1
  • Thanks shiva for the response. But this gives only the way to implement and get all the contacts loaded with all the data. But my requirement is different. I need to get the list of addressbooks and on getting the list i need to check for which all addressbooks the user have read permission. Thanks for helping. Please advice on the same.
    – bRajesh
    Jun 30, 2013 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.