lithnet / googleapps-managementagent

Google Workspace Management Agent for MIM 2016
MIT License
12 stars 4 forks source link

Organization fixed types #70

Closed briuccio closed 2 years ago

briuccio commented 2 years ago

Hello, I need an help in how to define the organization fixed type. Whatever I set on Schema - Organization Fixed types I can't retrieve user organization information (tried with "company","work","unknown", etc) I know that there are attributes under Organization, here an example in what I get with postman for my account: Capture

ryannewington commented 2 years ago

@briuccio

Something looks a little bit strange with your data. If the customType field is blank, there must be a type field that is not-blank.

So we should see a type attribute that contains domain_only, school, unknown, work or custom. If it is custom, then we should see a value in customType. In your case, there is no type and customType is an empty string.

The management agent wont be able to detect and manage these values, until the type (and customType, if 'type' is to be set to a custom value) values are set correctly.

briuccio commented 2 years ago

Hello, thank you for your answer. It looks strange to me, I did a couple of checks on our test environment and I can't see the organizations "type" (it is set to null) and "customType" is blank (same as production) even that, the agent can retrieve organizations parameters. The only parameter that differ is "primary" set to true (in production is null), I tried to set it to null in test environment too but nothing changes (I still can retrieve organization from test environment)

postman_test lithnet_test

ryannewington commented 2 years ago

In order for the MA to see then you'll need to set a type. Can you use something like GAM tool to set them all to type=work?

SirDester commented 2 years ago

Hello, I work with @briuccio and we analyzed the issue with the Organization field.

It seems that the difference between Test and Production environment is the presence of the "Primary=true" field. With this field set the properties of Organization are retrieved.

We downloaded the source code of managementagent and we noticed this function in the AdapterCustomTypeList<T> class:

    private bool SetPrimaryOnMissingType(T item)
    {
        if (!this.IsPrimaryCandidateType)
        {
            return false;
        }

        if (item.Type == null)
        {
            if (this.IsPrimary(item))
            {
                item.Type = this.PrimaryType;
                return true;
            }
        }

        return false;
    }

Viewing this when the Type is null the library searches for the "Primary" attribute on the Google item and, if found, "forces" the item type to the type declared as PrimaryType in the configuration. In this case, you can write any word you want in the Organization Fixed Type configuration (event if it's not a permitted value like domain_only, school, unknown, work or custom) and the values are retrieved.

We also noticed that the Organization Type on Google can't be set directly on the web console and it seems that when the Organization object is first created on Google User it's populated with Type=null, CustomType="", Primary=null by default.

Saying that, could it be an enhancement to add a configuration that forces the agent to use the first Organization found (that is it forces the item.Type = PrimaryType) even if it's not flagged as primary?

Thanks in advance. Maurizio.

ryannewington commented 2 years ago

Hi Maurizio,

Thanks for your work uncovering what seems like yet another google curoisity.

Is this situation coming about because you create some of this data in the Google console, and have MIM contribute the rest? Or are we dealing with a dataset that was once manually managed and you are now looking to manage it via MIM?

The reason I ask is that if it is just an artifact of a previous way of managing it, I'd suggest using something like the GAM tool to set them all to primary, and that should resolve the issue.

If you have a business workflow that's going to mean this will keep happening, I'm happy to explore what changes might look like to the MA, if we can do so in a way that doesn't involve obsure behind-the-scenes logic that might trip people up.

Ryan

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.