[Active Directory] Using the "Location" attribute in the ADUser structure

[Active Directory] Using the "Location" attribute in the ADUser structure

  
Forge Component
(11)
Published on 14 Nov by Renato Pauleta
11 votes
Published on 14 Nov by Renato Pauleta

Hi,

I love this plugin and have been very successful creating new users in our on-prem AD with it. The one thing I can not figure out is how to populate the city and country of a user with the "Location" attribute of the ADUser structure. The details of that field says it handles both, but no matter what I put in that field, it always winds up in the "state" field in our on-prem AD.

Being an international company, having the country field in our AD is kind of important, so could someone pass along how to get that info up to AD using the AD_UserCreate action (or another method)? it could be something obvious that I am just not seeing.

Thank you,

Scott

Hi Scott,

You'd need to extend the extension to also include the city and country. They're there, I just didn't create the methods to expose and change them in the UserPrincipalEx.cs.

As soon as I have time I'll add those methods, but if you can do it without waiting for me, then go for it.

Something like this:

        [DirectoryProperty(ADProperties.CITY)]
        public string City
        {
            get
            {
                if (ExtensionGet(ADProperties.CITY).Length != 1)
                    return null;

                return (string)ExtensionGet(ADProperties.CITY)[0];

            }
            set { this.ExtensionSet(ADProperties.CITY, value); }
        }
        [DirectoryProperty(ADProperties.COUNTRY)]
        public string Country
        {
            get
            {
                if (ExtensionGet(ADProperties.COUNTRY).Length != 1)
                    return null;

                return (string)ExtensionGet(ADProperties.COUNTRY)[0];

            }
            set { this.ExtensionSet(ADProperties.COUNTRY, value); }
        }


Then you'll need to also add new columns to the ADUser structure and make sure you assign both the get and set on the .NET code.

Cheers.

Renato Pauleta wrote:

Hi Scott,

You'd need to extend the extension to also include the city and country. They're there, I just didn't create the methods to expose and change them in the UserPrincipalEx.cs.

As soon as I have time I'll add those methods, but if you can do it without waiting for me, then go for it.

Something like this:

        [DirectoryProperty(ADProperties.CITY)]
        public string City
        {
            get
            {
                if (ExtensionGet(ADProperties.CITY).Length != 1)
                    return null;

                return (string)ExtensionGet(ADProperties.CITY)[0];

            }
            set { this.ExtensionSet(ADProperties.CITY, value); }
        }
        [DirectoryProperty(ADProperties.COUNTRY)]
        public string Country
        {
            get
            {
                if (ExtensionGet(ADProperties.COUNTRY).Length != 1)
                    return null;

                return (string)ExtensionGet(ADProperties.COUNTRY)[0];

            }
            set { this.ExtensionSet(ADProperties.COUNTRY, value); }
        }


Then you'll need to also add new columns to the ADUser structure and make sure you assign both the get and set on the .NET code.

Cheers.

Thank you so much for responding this quickly Renato and taking the time to give such a complete answer!

One of the other things I love about the Outsystems platform is that even novices can use it. Being one of those, I'll need to wait for you to make the above suggested change to the code. I'm just happy to know that is on your radar and will be glad to test it when ever it becomes available.

Thanks again and keep up the good work!


Solution

Thank you for your feedback Scott.

I've uploaded a new version which includes Country, Country Code, City and Division. Removed Location (was being used to show City).

I've also needed to update to the latest CryptoAPI version (2.0.1), so you'll probably need to update this one as well.


Let me know if it worked.


Cheers.

Solution

Renato,

Your updates to the extensions worked perfectly! Thank you so much for taking the time to make this happen.

Best,

Scott

That's great Scott!

I'm glad it worked. If you need anything else let us know.

Cheers.