Strange behavior of the Organizational Structure Configuration File

Source: Internet
Author: User

The organizational structure configuration file (organizationprofile) may be unfamiliar to you, especially for programming access. I will not list the specific operations here. The SDK also provides examples. Here we will only describe an API behavior that may not be the same as our expectation.

In the organization structure configuration file, members in an organization are divided into two types: Leader and member. You can use the addmember method of organizationprofile to add users to the two parts (using a parameter to identify whether it is leader or member) and delete it through removemember.

If this user is not in member, we can use the following sentence to add user1 as a leader.

   1: orgProfile.AddMember("domain\\user1", 
   2:               OrganizationMembershipType.Leader);

Assume that there is no one in the previous organization. After executing the above sentence, user1 will both appear in leader and member, that is to say, this user will be automatically added to the member at the same time. This behavior is easy to understand and also make sense.

But! (Coming again)

Assume that user1 is already a leader at this time (of course, it is also a member). Check the following code:

   1: orgProfile.AddMember("domain\\user1",    
   2:               OrganizationMembershipType.Member);

What do you think will happen after executing this sentence? Add user1 as member again. Do you think there should be no changes under the above assumptions? Wrong! When we finish this sentence, user1 is still in member, but it has been removed from leader. It's strange ...... I believe this is a by design bug ......

In other words, to add a user as a member, you must first check whether the user is already in the member. If the user already exists, do not add it again. Otherwise, if this user is the leader of this organization, the leader will be gone as soon as you add (what a terrible behavior this is in a project in China)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.