Pergunta

I am working with updating groups programmatically and have been wondering how SPGroup's react when you:

a) Try to remove people that are not already a member - silently fail, throw exception, ??
b) Try to add a person to a group he is already a member of - again, with what outcome.

Since MSDN do not document Exception-handling (at all) I tried google but I can't seem to find any articles with my google-fu that will give me the right answer.

Any and all help is appreciated.

Foi útil?

Solução

In both cases nothing will happen because there is nothing to do on SPGroup.Update(). If you are trying to add user that already exist - it's already there and if you are trying to remove user who is not member of group - there is nothing to remove.

Your code will continue as normal and no exception will be thrown.

I personally find this 'malfunction' to be very useful especially in case where you are programmatically doing bulk SPGroup updates.

Outras dicas

I can only provide anacdotal evidence to this question. In some Nintex workflows we have, we are adding users to groups via the web services. When a user is already in the group, the workflow continues on, the workflow does not error. I haven't tried to decipher if it is readding the user or if it is just aborting and silently continuing because the user is there.

I have not tried to remove users from a group via the web services in a workflow so I don't have any evidence to give you on that.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top