ALTER PROCEDURE [user_sp].[GetUserInfo]
	@UserID				UNIQUEIDENTIFIER=NULL,
	@AdDomain			NVARCHAR(75)=NULL,
	@AdAccount			NVARCHAR(75)=NULL,
	@AuthenticationType NVARCHAR(50)
AS
BEGIN
	SET NOCOUNT ON;
	IF(@UserID IS NULL)
		BEGIN
			SELECT @UserID = [UserID]
			  FROM user_tbl.[User] LEFT OUTER JOIN user_tbl.ClientLicenseTypes RIGHT OUTER JOIN user_tbl.ClientLicense 
				ON user_tbl.ClientLicenseTypes.ClientLicenseTypeID = user_tbl.ClientLicense.ClientLicenseTypeID 
				ON user_tbl.[User].ClientLicenseID = user_tbl.ClientLicense.ClientLicenseID
			 WHERE (AdAccount = @AdAccount) 
			   AND (AdDomain  = @AdDomain)
		END
		
		SELECT					usr.UserID, usr.FirstName, usr.LastName, usr.UserSettings, usr.ClientLicenseID, usr.AdDomain AS Domain, usr.AdAccount AS UserName, usr.AdSid, usr.SocialNetworkUserDetails,
								usr.AdGuid, usr.AdminType, clt.Description AS LicenseTypeDesc, clt.ClientLicenseTypeID, usr.LastLoginDate, lic.EncryptedLicenseKey as LicenseKey
		FROM					
								user_tbl.ClientLicenseTypes AS clt 
								RIGHT OUTER JOIN
								user_tbl.License AS lic 
								INNER JOIN
								user_tbl.ClientLicense AS cl ON lic.LicenseID = cl.LicenseID ON clt.ClientLicenseTypeID = cl.ClientLicenseTypeID RIGHT OUTER JOIN
								user_tbl.[User] AS usr ON cl.ClientLicenseID = usr.ClientLicenseID
		WHERE					usr.UserID = @UserID
	
	SELECT RoleID 
	  FROM user_tbl.UserRoles
	 WHERE UserID = @UserID
	 
	DECLARE @logDate datetime 
	SET @logDate = GETDATE()
	
	UPDATE user_tbl.[User]
	   SET LastLoginDate = @logDate
	 WHERE UserID = @UserID

END

Go
												   



ALTER PROCEDURE [content_sp].[ChangeCmcsHierarchy] 
	-- Add the parameters for the stored procedure here
		@ID						As UniqueIdentifier
		,@Address				As nVarChar(500)
		,@CatalogName			As nVarChar(500)
		,@CubeName				As nVarChar(500)
		,@UserId				As UniqueIdentifier
		,@CustomSecurityType	As Int
		,@SerializedData		As nVarChar(MAX)
	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	BEGIN TRY
		Update content_tbl.CustomMembersCustomSets 
		Set [Address] = @Address     									,		
			CatalogName = @CatalogName 									,		
			CubeName = @CubeName    									,		
			ModifyDate = GETDATE()										,		
			CustomSecurityType = @CustomSecurityType					,		
			UserID = @UserId											,
			CustomObjectSerializedData = @SerializedData
		Where ID = @ID
	
		if (@CustomSecurityType = 0) --Private
		begin
			Delete From content_tbl.RoleCustomElementsGroups Where CustomItemID = @ID
		end
	
	END TRY
	
	BEGIN CATCH
		EXEC dbo.AddEventLogMessage
	END CATCH	
END


GO