Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationDynamic Property LoaderDynamic Property Loader
Previous
 
Next
New Post
11/19/2007 5:29 PM
 

Some of my AD properties don't line up with the default provided in the code.  There are also some additional properties I would like to automagically stick into a user's profile.  Here is my take on a solution to that problem:

ADSIMap.xml  (Add to Portal Directory - adjust fields to meet your needs)

<ADSI>
    <UserInfo>
        <Email>mail</Email>
        <CName>cn</CName>
        <DisplayName>displayName</DisplayName>
        <DistinguishedName>distinguishedName</DistinguishedName>
        <sAMAccountName>sAMAccountName</sAMAccountName>
    </UserInfo>
    <Profile>
        <FirstName>givenName</FirstName>
        <LastName>sn</LastName>
        <City>companyCampusCode</City>
        <Region>companySiteCode</Region>
        <Country>companyRegionCode</Country>
        <EmployeeID>employeeID</WWID>
        <ManagerID>manager</ManagerWWID>
        <BadgeType>employeeBadgeType</BadgeType>
    </Profile>
</ADSI>

 

ADSIProvider.vb

Imports System.IO
Imports System.Reflection
Imports System.Xml
.....

Private Sub FillUserInfo(ByVal UserEntry As DirectoryEntry, ByVal UserInfo As UserInfo)

    With UserInfo
    .IsSuperUser = False
    .Username = UserInfo.Username
    .Membership.Approved = True
    .Membership.LastLoginDate = Date.Today()
    .Email = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_EMAIL).Value)
    .CName = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_CNAME).Value.ToString)
    .DisplayName = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_DISPLAYNAME).Value)
    .DistinguishedName = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_DISTINGUISHEDNAME).Value.ToString)
    .sAMAccountName = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_ACCOUNTNAME).Value.ToString)
    .Profile.FirstName = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_FIRSTNAME).Value)
    .Profile.LastName = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_LASTNAME).Value)
    .Profile.Street = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_STREET).Value)
    .Profile.City = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_CITY).Value)
    .Profile.Region = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_REGION).Value)
    .Profile.PostalCode = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_POSTALCODE).Value)
    .Profile.Country = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_COUNTRY).Value)
    .Profile.Telephone = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_TELEPHONE).Value)
    .Profile.Fax = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_FAX).Value)
    .Profile.Cell = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_CELL).Value)
    .Profile.Website = Utilities.CheckNullString(UserEntry.Properties(Configuration.ADSI_WEBSITE).Value)
    .AuthenticationExists = True

    If File.Exists(System.IO.Path.Combine(_portalSettings.HomeDirectoryMapPath(), "ADSIMap.xml")) Then
        Dim properties As ProfilePropertyDefinitionCollection = .Profile.ProfileProperties()
        Dim objProfileController As ProfileController = New ProfileController()
        Dim objProfileProperties As ProfilePropertyDefinitionCollection = objProfileController.GetPropertyDefinitionsByPortal(_portalSettings.PortalId)
        Dim fieldPropertyDef As ProfilePropertyDefinition
        Dim fieldPropertyInfo As PropertyInfo
        Dim userInfoNode As XmlNode

        Dim adsiMapDoc As New XmlDocument()
        adsiMapDoc.Load(System.IO.Path.Combine(_portalSettings.HomeDirectoryMapPath(), "ADSIMap.xml"))

        For Each userInfoNode In adsiMapDoc.SelectNodes("ADSI/UserInfo/*")
        fieldPropertyInfo = UserInfo.GetType().GetProperty(userInfoNode.LocalName())
        If Not fieldPropertyInfo Is Nothing Then
            fieldPropertyInfo.SetValue(UserInfo, Utilities.CheckNullString(UserEntry.Properties(userInfoNode.InnerText).Value), Nothing)
        End If
        Next

        For Each userInfoNode In adsiMapDoc.SelectNodes("ADSI/Profile/*")
        fieldPropertyDef = properties.GetByName(userInfoNode.LocalName())
        If Not fieldPropertyDef Is Nothing Then
            .Profile.SetProfileProperty(fieldPropertyDef.PropertyName, Utilities.CheckNullString(UserEntry.Properties(userInfoNode.InnerText).Value))
        End If
        Next
    End If

    If .DisplayName = String.Empty Then
        .DisplayName = .CName
    End If
    If .Profile.FirstName.Length = 0 Then
        .Profile.FirstName = Utilities.TrimUserDomainName(UserInfo.Username)
    End If
    End With
End Sub

 

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsAuthenticationAuthenticationDynamic Property LoaderDynamic Property Loader


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out