Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

DotNetNuke Marketplace
  Ads  
Iron Speed Designer is a software development tool for building database, reporting, and forms applications for .NET without hand-coding.
 


  Sponsors  

Meet Our Sponsors

Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
AspDotNetStoreFront - E-Commerce by Design - The Leading ASP.NET shopping cart platform for developers!
SteadyRain
DataSprings - Great Ideas. Always Flowing.
R2integrated - formerly bi4ce
 


DotNetNuke Forums
 
  Forum  DotNetNuke® Pro...  Authentication ...  Dynamic Property Loader
Previous Previous
 
Next Next
New Post 11/19/2007 2:29 PM
User is offline John Hoskins
65 posts
10th Ranked


Dynamic Property Loader 

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 Previous
 
Next Next
  Forum  DotNetNuke® Pro...  Authentication ...  Dynamic Property Loader
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


PointClick DotNetNuke Solutions
PointClick Technologies provides high-end DNN Hosting for businesses.
PointClick.Net Hosted Solutions
Active Modules, Inc.
Creators of Active Forums, the best forum module for DotNetNuke
www.activemodules.com
DotNetNuke Marketplace - Modules & Skins
The DotNetNuke Marketplace is the official e-commerce gateway for the DNN ecosystem. It's the place to buy and sell DotNetNuke modules, DotNetNuke skins, and other DNN offerings.
DotNetNuke Marketplace

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP