SDK を使用して CRM 4.0 に新しいユーザーを追加するサンプル コードはありますか?
3274 次
2 に答える
2
別のシステムのユーザーに基づいてユーザーを作成するコードがあるため、ここにすべてを正確に貼り付けることはできません.
[VB で申し訳ありません :-) - また、ここに VB を投稿するときに、書式を正しくするためにコメントを示すために「//」を使用する必要があることがわかりました]
Public Sub CreateNewUser()
Dim s as mscrm.CrmService = GetMyService()
Dim newUser as New mscrm.systemuser()
With newUser
.domainname = "domain\user"
.firstname = "Stan"
.lastname = "Molda"
//set anything else you want here
End With
Dim userGuid as guid = s.Create(newUser)
//Next we need to assign the user a role
AssignRole(userGuid)
//Finally we need to assign them to the correct Time Zone
SetUserTimeZone(userGuid)
End Sub
Public Sub AssignRole(g as Guid)
Dim s as mscrm.CrmService = GetMyService()
Dim req As New mscrm.AssignUserRolesRoleRequest()
req.UserId = g
req.RoleIds = New Guid() {GetTheGuidForMyPrimaryRole()}
s.Execute(req)
End Sub
Public Sub SetUserTimeZone(g as Guid)
Dim s as mscrm.CrmService = GetMyService()
Dim r As New mscrm4.RetrieveUserSettingsSystemUserRequest()
r.ColumnSet = New mscrm3.AllColumns()
r.EntityId = New Guid(g)
Dim resp As mscrm.RetrieveUserSettingsSystemUserResponse = CType(s.Execute(r), mscrm.RetrieveUserSettingsSystemUserResponse)
Dim settings As mscrm.usersettings = CType(resp.BusinessEntity, mscrm.usersettings)
settings.timezonecode = New mscrm.CrmNumber
settings.timezonecode.Value = OUR_TIME_ZONE_CONSTANT
Dim update As New mscrm.UpdateUserSettingsSystemUserRequest()
update.Settings = settings
update.UserId = g
s.Execute(update)
End Sub
于 2009-11-25T19:43:29.037 に答える
1
C#については、私の質問であるDynamics CRM:特定のGUIDを使用してユーザーを作成します。これにより、必要な処理が正確に実行されます(ただし、必要な機能は正確には実行されません:-P)。
于 2010-03-02T20:59:19.630 に答える