This ended up being one of those simple commands to create that took way to long to figure out how to create. Fortunately though there is an API available for setting this property (unlike most of the profile import related tasks such as the timer jobs). You can set this manually by going here: Shared Services Administration: SSPName > User Profile and Properties > Configure Profile Import. Or you can do the same thing programmatically using UserProfileConfigManager
object – you need to get a DataSource object from an instance of the UserProfileConfigManager
and then set the value using the SetDefaultImportAccount()
method of the DataSource
object:
1public static void UpdateAccount(string sspname, string username, string password)
2{
3 ServerContext context;
4 if (string.IsNullOrEmpty(sspname))
5 context = ServerContext.Default;
6 else
7 context = ServerContext.GetContext(sspname);
8
9 UserProfileConfigManager prof = new UserProfileConfigManager(context);
10
11 DataSource dataSource = prof.GetDataSource();
12
13 dataSource.SetDefaultImportAccount(username, password);
14}
The syntax of the command I created to do this can be seen below.
C:\>stsadm -help gl-setuserprofiledefaultaccessaccount
stsadm -o gl-setuserprofiledefaultaccessaccount
Sets default access account for user profiles.
Parameters:
-username <DOMAIN\name>
-password <password>
[-sspname <name of the SSP>]
The following table summarizes the command and its various parameters:
Command Name | Availability | Build Date |
---|---|---|
gl-setuserprofiledefaultaccessaccount | MOSS 2007 | Released: 8/9/2007, Updated: 8/14/2008 |
Parameter Name | Short Form | Required | Description | Example Usage |
---|---|---|---|---|
username | u | Yes | The user account name. | -username "domain\name" , -u "domain\name" |
password | p | Yes | The account password. | -password "pa$$w0rd" , -p "pa$$w0rd" |
sspname | ssp | No | name of the SSP for which to set the user profile account. If not specified then the default SSP is used. | -sspname SSP1 , -ssp SSP1 |
Here’s an example of how to set the default access account:
stsadm –o gl-setuserprofiledefaultaccessaccount –sspname SSP1 –username "domain\login" -password "password"
Note that if you intend to use this in a script make sure you are real careful about where you store that script as the password is obviously going to be stored in clear text which isn’t a good thing. Also, you’ll notice that I use the SSP name instead of the url - you can change the code to use the url but I found that working with the SSP name was more convenient.
Update 8/14/2008: I’ve made it so that the SSP is now an optional parameter.