In this example, I’m going to create a custom field in Active Directory for birth year so that we can pull it into the portal from AD.
Step 1: Edit the Active Directory Schema
- Open an MMc console
- Add active directory schema as a snap-in. If it isn’t available, you will need to follow these directions. https://www.briandesmond.com/active-directory/how-to-register-active-directory-schema-mmc-snap-in/
- Inside active directory schema right click attributes and choose Create Attribute
- Enter a common name. I’m going to use personBirthYear for my example. You can call this whatever you like.
- Put in a description
- Choose a Syntax. I’m going to use integer for mine.
- Create a Unique OID. I’m using the following power shell script to produce mine.
#---
$Prefix="1.2.840.113556.1.8000.2554"
$GUID=[System.Guid]::NewGuid().ToString()
$Parts=@()
$Parts+=[UInt64]::Parse($guid.SubString(0,4),"AllowHexSpecifier")
$Parts+=[UInt64]::Parse($guid.SubString(4,4),"AllowHexSpecifier")
$Parts+=[UInt64]::Parse($guid.SubString(9,4),"AllowHexSpecifier")
$Parts+=[UInt64]::Parse($guid.SubString(14,4),"AllowHexSpecifier")
$Parts+=[UInt64]::Parse($guid.SubString(19,4),"AllowHexSpecifier")
$Parts+=[UInt64]::Parse($guid.SubString(24,6),"AllowHexSpecifier")
$Parts+=[UInt64]::Parse($guid.SubString(30,6),"AllowHexSpecifier")
$OID=[String]::Format("{0}.{1}.{2}.{3}.{4}.{5}.{6}.{7}",$prefix,$Parts[0],$Parts[1],$Parts[2],$Parts[3],$Parts[4],$Parts[5],$Parts[6])
$oid
#---
- Expand the classes folder in Schema and find user
- Right click user and choose properties
- Choose Attributes
- Click Add
- Find the Object you created. In my case it is personBirthYear
- Add the object. Note sometimes my mmc console crashes at this step but it always seems to add the object.
- At this point you will need to restart the Active Directory service in services. Once that has finished your object will be available in AD users and computers under Attribute Editor.
Step 2: Edit the Web.config file
- On the web server go to the site root folder. Usually C:\inetpub\wwwroot\your portal name
- Find web.config
- Open it and find the following line
<add name="ActiveDirectoryUserProfile" description="Active Directory" connectionStringName="LDAP" attributeMapUserName="sAMAccountName" type="Passageways.Portal.Web.UserProfiles.ActiveDirectoryUserProfileProvider, Passageways.Portal.Web" />
- Add fieldNames="personBirthDay" just after connectionStringName="LDAP". In your case personBirthDay will be the name of the object you created in AD Schema. The line will look like this when done.
<add name="ActiveDirectoryUserProfile" description="Active Directory" connectionStringName="LDAP" fieldNames="personBirthDay" attributeMapUserName="sAMAccountName" type="Passageways.Portal.Web.UserProfiles.ActiveDirectoryUserProfileProvider, Passageways.Portal.Web" />
**note** If you wanted to add more than one field you can do it by using commas in-between. For example, here’s a line adding personBirthDay and PersonBirthYear.
<add name="ActiveDirectoryUserProfile" description="Active Directory" connectionStringName="LDAP" fieldNames="personBirthDay,personBirthYear" attributeMapUserName="sAMAccountName" type="Passageways.Portal.Web.UserProfiles.ActiveDirectoryUserProfileProvider, Passageways.Portal.Web" />
- Save the web.config and close it
Step 3: Add the field into the portal.
- Open the portal and go to Manage users>Profile Field Manager
- Click New Field
- Field type select Text Box
- Label: call it what you like. I’ll call mine birth year
- Select Active Directory as the provider
- Under Select Field your new field object should be available
- In my case I’m going to do something a little unique and use my new field under an existing field option in the portal called Birth Year.
Comments
0 comments
Please sign in to leave a comment.