joi, 4 august 2016

SQL SERVER : sp_who2 Replacement

SELECT  spid,
        sp.[status],
        loginame [Login],
        hostname,
        blocked BlkBy,
        sd.name DBName,
        cmd Command,
        cpu CPUTime,
        physical_io DiskIO,
        last_batch LastBatch,
        [program_name] ProgramName  
FROM master.dbo.sysprocesses sp (nolock)
JOIN master.dbo.sysdatabases sd ON sp.dbid = sd.dbid
--WHERE sp.hostname like '%654%'
--ORDER BY spid
ORDER by
login
--cpuTime desc

luni, 1 august 2016

Fixing AD issues for CRM

select

 crmuserid  --reference to the SystemUserId in CRM
,suo.userid  --reference to the SystemUserAuthentication table

,AuthInfo
,domainname
,fullname

,sua.Id


from

[MSCRM_CONFIG].[dbo].SystemUserOrganizations  suo

LEFT JOIN [MSCRM_CONFIG].[dbo].SystemUserAuthentication sua
ON suo.UserId = sua.UserId


LEFT JOIN Row2015_MSCRM.dbo.systemuser su
ON suo.CrmUserId = su.SystemUserId

where
suo.OrganizationId =
(
select ID from MSCRM_CONFIG.dbo.Organization where UniqueName = 'Row2015'
)


and su.DomainName like '%Xacv622test1%'

--W:S-1-5-21-1659004503-2025429265-725345543-164647
--W:S-1-5-21-1659004503-2025429265-725345543-184821


update [MSCRM_CONFIG].[dbo].SystemUserAuthentication
set AuthInfo = 'W:S-1-5-21-1659004503-2025429265-725345543-184821'

where id = 'A3E25B91-97EB-E511-80D3-005056AC11FA'


$objUser = New-Object System.Security.Principal.NTAccount("DOMAIN", "USERNAME") 
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier]) 
$strSID.Value


http://www.celedonpartners.com/blog/reconnecting-active-directory-accounts-in-dynamics-crm/