사용자 프로필 가져오기 도구(Profile Import Tool) 릴리즈
폼 인증 적용 시, 사용자 프로필을 외부 DB로부터 가져오는 작업을 손쉽게 처리할 수 있도록 도와주는 Profile Import Tool이 릴리즈되었습니다; [다운로드]
자세한 사용 방법은 다음 readme 파일 내용을 참고해 주십시오.
Import Provider Configuration File Settings
The Import Provider feature reads its configuration information from the configuration file. The configuration process involves the following steps:
1. Register the Configuration Hander
2. Register the SQL Connection Strings
3. Register the Membership Providers
4. Register the Profile Providers
5. Register the Import Providers
Register the Configuration Handler
You must first register the configuration handler for the Import Provider feature. This allows the runtime to load the proper configuration handler for reading the <ImportProvider> element.
Paste the following section (as-is) into the ProfileImporter.exe.config file. Note: Be sure to add the <section> element as a child of <configuration><configSections> .
<section name="ImportProvider" type="IW.MOSS.CustomProviders.ImportProviderConfiguration, IW.MOSS.CustomProviders" allowDefinition="MachineToApplication" /> |
Register the SQL Connection Strings
If you are using SQL-based providers, you must register the connection string used by each. The declaration process follows the normal ASP.Net process for declaring a connection string; there is nothing unique to the Import Provider feature.
Paste a section, similar to the following, into your configuration file. The following example declares two connection strings, one for the Membership database and one for the Profile database.
<connectionStrings> <remove name="localMembershipDatabase" /> <add name="localMembershipDatabase" connectionString="server=<serverName>; database=aspnetdb; Trusted_Connection=True" /> <remove name="localProfileDatabase" /> <add name="localProfileDatabase" connectionString="server=<serverName>; database=aspnetdb; Trusted_Connection=True" /> </connectionStrings> |
Note: Be sure to add the <connectionStrings> element as a child of <configuration> :
Register the Membership Providers
You must register any membership provider that you wish to use. The Import Provider feature leverages the standard ASP.Net membership provider interface. As such, the declaration process follows the normal ASP.Net process for declaring a membership provider; there is nothing unique to the Import Provider feature.
You are free to use the Out-of-the-Box ASP.Net membership providers, or you may leverage the ASP.Net Membership Provider Interface and create/register a custom provider of your own.
Paste a section, similar to the following, into your configuration file. The following example declares two SQL-based membership providers, one for the Contoso membership database and one for the Fabrikam membership database. Note that each has a unique application name, which will result in two distinct collections of users in the MOSS User Profile Database (Contoso:XXXXX and Fabrikam:XXXXX).
<membership defaultProvider="ContosoMembership"> <providers> <remove name="ContosoMembership" /> <add name="ContosoMembership" connectionStringName="localMembershipDatabase" applicationName="Contoso" passwordAttemptWindow="10" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" passwordFormat="Hashed" description="Stores and retrieves membership data from the Microsoft SQL Server database" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <remove name="FabrikamMembership" /> <add name="FabrikamMembership" connectionStringName="localMembershipDatabase" applicationName="Fabrikam" passwordAttemptWindow="10" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="false" passwordFormat="Hashed" description="Stores and retrieves membership data from the Microsoft SQL Server database" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> </membership> |
Note: Be sure to add the <membership> element as a child of <system.web>
Register the Profile Providers
The use of a Profile Provider is optional; the ImportProvider feature does not require the use of a Profile Provider. However, you must register any profile provider that you wish to use. The Import Provider feature leverages the standard ASP.Net Profile provider interface. As such, the declaration process follows the normal ASP.Net process for declaring a profile provider; there is nothing unique to the Import Provider feature.
You are free to use the Out-of-the-Box ASP.Net profile providers, or you may leverage the ASP.Net Profile Provider Interface and create/register a custom provider of your own.
The <profile> declaration has two major sections:
1. The <properties> section declares the properties that each provider can return
a. The "name" attribute of each property entry corresponds to the internal name that the MOSS User Profile DB uses for that property. You will need to examine the user profile properties in order to determine the value of this attribute.
b. If you declare a property entry for a property that is marked as Required in the user profile properties, each profile provider must provide a value for that property when asked. You will need to examine the user profile properties in order to determine if the property is required.
c. The "defaultValue" attribute allows you to declare the default value to be returned in the event that a property is not supported by a provider.
2. The <providers> section declares the providers themselves.
Paste a section, similar to the following, into your configuration file. The following example declares two profile providers, a custom text file-based profile provider for the Contoso profile database and a SQL-based profile provider for the Fabrikam profile database. Note that we provide a default value for those properties that are marked as Required in the user profile properties.
<profile defaultProvider="ContosoProfile"> <!-- The "name" attribute of each property entry corresponds to the internal name that the MOSS User Profile DB uses for that property. If you declare an entry for a property that is marked in the UPDB as Required, each profile provider must provide a value for that property. The "defaultValue" attribute provides the value to be returned in the event that a property is not supported by a provider. --> <properties> <add name="FirstName" /> <add name="LastName" /> <!-- Required UPDB properties follow... --> <add name="PreferredName" defaultValue="Not present in Profile DB"/> <add name="WorkEmail" defaultValue="unknown@litwareInc.com" /> <add name="WorkPhone" type="System.String" defaultValue="Not present in Profile DB" /> </properties> <providers> <add name="ContosoProfile" type="IW.MOSS.SampleProviders.TextFileProfileProvider, IW.MOSS.SampleProviders"/> <add name="FabrikamProfile" type="System.Web.Profile.SqlProfileProvider" connectionStringName="localProfileDatabase" applicationName="Fabrikam" /> </providers> </profile> |
Note: Be sure to add the <profile> element as a child of <system.web> :
Register the Import Providers
Now that all of the pre-requisites have been satisfied, you can declare the Import Providers.
The Import Provider section is unique to the Import Provider feature. It declares the logical import providers that participate in the Import Provider feature. You may declare zero or more providers.
For each entry (all attributes are required unless noted otherwise):
· name – a logical name used to identify the source/purpose of the import operation
· type – always “IW.MOSS.CustomProviders.ImportProvider, IW.MOSS.CustomProviders”
· description – a verbose description of the source/purpose of the import operation
· membershipProvider – the name of the membership provider (registered above) to use
· profileProvider (optional) – the name of the profile provider (registered above) to use
Paste a section, similar to the following, into your configuration file. The following example declares two import providers, one provider for Contoso and one provider Fabrikam. Note that each provider includes the both membership and profile information. It does this so that the Import Provider application knows which Membership provider it should use to get the list of users. For each user that the Membership provider returns, the Import Provider application will use the associated profileProvider to get a list of all the profile properties for that user.
<ImportProvider defaultProvider="ContosoImport"> <providers> <add name="ContosoImport" type="IW.MOSS.CustomProviders.ImportProvider, IW.MOSS.CustomProviders" description="custom import provider" membershipProvider="ContosoMembership" profileProvider="ContosoProfile" /> <add name="FabrikamImport" type="IW.MOSS.CustomProviders.ImportProvider, IW.MOSS.CustomProviders" description="custom import provider" membershipProvider="FabrikamMembership" profileProvider="FabrikamProfile" /> </providers> </ImportProvider> |
Note: Be sure to add the <ImportProvider> element as a child of <configuration> :
The config changes described here allow you to reuse any out of the box membership and profile providers that you are already using. As long as your membership provider returns a list of all users in the GetAllUsers method and as long as the profile provider returns a list of properties for each of those users, then no custom development is required.
If you don’t have a membership and profile provider that meets those criteria, you can also write a custom class that inherits the IW.MOSS.CustomProviders.ImportProvider class provided with this tool. Then override the GetAllUsers and/or GetAllProperties method to return users and/or properties for users. After you’ve compiled your assembly and registered it in the Global Assembly Cache (GAC) you can register it in the <providers> section as described above; just make sure to change the “type” attribute to the class and assembly name for your custom code.
Running the Import Provider Tool
The Import Provider tool is called ProfileImporter.exe and is located in the Providers\Driver\bin\Debug directory. It is intended to be run as a console application; this gives you the flexibility to run it on demand, or to schedule it to be run at appropriate intervals for your MOSS environment. All of the config changes described above should be made in the ProfileImporter.exe.config file that is in the same directory as the application.
Once all of the config changes have been made, run the application with the /run parameter, i.e.:
Profileimporter.exe /run
Doing so starts the application and it will process all of the providers listed in the ProfileImporter.exe.config file. If you start the application without the /run parameter then it starts up a simple Windows test application.
Any errors that occur during processing are output to the console screen. In addition they are written to the event log so that they can be reviewed later, have alerts triggered for them, etc.