Although this is an unsupported way, we still need to get this sometimes... a developer hack :)
SET @DomainName = 'domain\username'--e.x. 'sandnes\ganesh'
DECLARE @Id AS UNIQUEIDENTIFIER
DECLARE @UserId AS UNIQUEIDENTIFIER
DECLARE @RoleId AS UNIQUEIDENTIFIER
SELECT @RoleId = id
FROM mscrm_config..securityrole
WHERE NAME = 'Administrator'
SELECT @UserId = id
FROM mscrm_config..systemuser
WHERE NAME = @DomainName
IF ( @UserId IS NULL )
BEGIN
SET @UserId = Newid()
INSERT INTO mscrm_config..systemuser
(id,
NAME,
defaultorganizationid)
VALUES (@UserId,
@DomainName,
'00000000-0000-0000-0000-000000000000')
END
SELECT @Id = id
FROM mscrm_config..systemuserroles
WHERE systemuserid = @UserId
IF ( @Id IS NULL )
BEGIN
SET @Id = Newid()
INSERT INTO mscrm_config..systemuserroles
(id,
securityroleid,
systemuserid)
VALUES (@Id,
@RoleId,
@UserId)
END
No comments:
Post a Comment